MONTREAL -- Canadian National Railway beat analyst expectations as its profits grew 20 per cent to $1.03 billion in the second quarter on higher revenues.

The Montreal-based railway (TSX:CNR) earned $1.36 per diluted share, up from $1.10 a year earlier when it posted $858 million in net income.

Excluding a tax recovery, the railway earned $1.01 billion or $1.34 per share for the period ended June 30. That's up from $865 million or $1.11 per share in the second quarter of 2016.

Revenues grew 17 per cent to $3.3 billion.

CN Rail was expected to earn $1.31 per share in adjusted profits on $3.25 billion of revenues, according to analysts polled by Thomson Reuters.

Railway president and CEO Luc Jobin said the country's largest railway delivered a solid performance on strong volume growth.

"The North American economic outlook continues to be positive, and we remain committed to delivering on our 2017 financial outlook," he said in a statement.

"However, volume comparisons in the second half of the year will be more challenging, and the strengthening of the Canadian dollar will constitute a headwind."

The operating ratio, a measure of efficiency that balances revenue with expenses, worsened by 60 basis points to 55.1 per cent over the prior-year quarter.

Revenues increased for all product categories led by metals and coal, which were both up by 33 per cent. Grains and fertilizers increased 23 per cent, automotive 20 per cent, intermodal 17 per cent, petroleum and chemicals 12 per cent, and forest products six per cent.