MONTREAL - Canada's two largest railways have settled a legal dispute that erupted after an employee moved from one rival to the other, allegedly taking confidential information with him.

Montreal-based Canadian National Railway Co. (TSX:CNR) says rival Canadian Pacific Railway Ltd. agreed to pay $25 million to settle the case, and agreed it wouldn't hire certain CN employees until Dec. 31, 2018.

Calgary-based CP (TSX:CP) says the settlement doesn't admit liability on the part of the company.

The settlement was mentioned in brief statements contained in the companies' third-quarter financial reports, issued by both railways last month.

A lawsuit filed by CN in August 2015 claimed it lost rail freight business and market share after employee Greg Shnerer quit to join CP, and took with him information that included customer contracts, pricing information and business plans.

CN also alleged that a CP manager encouraged Shnerer to download confidential information from CN's databases in June 2015, while he was still employed there.