The agreement was reached less than an hour after the railway’s 11 p.m. ET deadline to lock out mechanical, intermodal and clerical workers.
Negotiations between the two sides had resumed Monday morning with the help of federal mediation advisers and continued beyond the late-night deadline.
Unifor president Jerry Dias told The Canadian Press that the deal "came together when the company realized that the government was not going to interfere."
"Once the company realized that they had to negotiate an agreement with us, then things fell into place," he said in a telephone interview.
Dias said federal Labour Minister Kellie Leitch played an important role by telling the two sides they had to negotiate a settlement.
"The company was going to push a lockout and the facts are that the government was not going to interfere," said Dias.
Leitch issued a statement after the deal was struck saying she was "very pleased" that an agreement was reached to eliminate any threat to the Canadian economy.
"I know that it will benefit not only the parties involved but all Canadians. I firmly believe that the best solution is always the one that the parties reach themselves," she said.
In a separate statement, CN president and CEO Claude Mongeau said the railway was also very pleased that both sides found common ground on a tentative contract.
"This settlement forecloses the prospect of a potential labour disruption that would have harmed CN's employees, its customers and the Canadian economy," he said.
The Montreal-based railway had said it planned to lock out the workers unless Unifor agreed to binding arbitration to settle contract differences.
Dias had spoken out firmly against binding arbitration in the belief that CN and Unifor could reach a settlement on their own.
"If we can't find a solution, then shame on us. We don't need somebody else to stick their nose in our business. We should be able to settle it ourselves."
Unifor said ratification meetings would be held across the country over the next three weeks. It said details of the agreement will only be disclosed after ratification.
Last week, the threat of federal legislation prompted CP Rail and the Teamsters to end a one day strike by 3,300 locomotive engineers and other train workers.