Canadian Pacific Railway will merge with the U.S. company Kansas City Southern (KCS) and will create the first railroad to directly cross Canada, the United States, and Mexico, countries that are part of the North American Trade Agreement (T-MEC).

The Canadian firm reached a cash and stock agreement for 27.2 billion dollars to buy Kansas City Southern after Canadian National Railway admitted it could not save its own 29.6 billion dollar deal for the US railroad company.

The merger will create a direct railroad linking Canada, the United States, and Mexico, with a network covering 32 thousand kilometers and approximately 8.7 billion in annual revenues.

The $300-per-paper cash-and-stock deal Canadian Pacific got is higher than the $275-per-stock cash-and-stock deal it had proposed in March to buy Kansas City Southern. That deal was canceled when Canadian National negotiated with Kansas City Southern in May with a cash-and-stock offer of $325 per share.

Canadian National suffered a blow when the U.S. Surface Transportation Board (STB) regulator last month rejected a temporary "voting trust" structure, which would have allowed Kansas City Southern shareholders to receive consideration for the deal without having to wait for full regulatory approval.

Canadian Pacific has obtained approval of its proposed voting trust from the STB, so Kansas City Southern shareholders will receive the $300 per share in cash and stock, even if the regulator rejects the deal.

The regulatory certainty this provided convinced Kansas City Southern's board of directors to switch to a deal with Canadian Pacific, even though its offer was lower than Canadian National's. Canadian National had also faced pressure from some of its investors, including hedge fund TCI Management, to abandon its attempt to buy Kansas City Southern.

Canadian National shares rose 3.7 percent on Wednesday - the day the deal was unveiled - to C$150.97 on the Toronto Stock Exchange, as its investors expressed relief at the abandonment of the deal attempt. On Thursday, the shares fell 0.64 percent to 146.85 Canadian dollars, while on the New York Stock Exchange they were down 1.31 percent to 115.76 dollars per share, but in post-market trading, they resumed their upward trend, with an increase of 0.03 percent to 115.80 dollars per share.