Exhibit 5.1
Consent of Independent Registered Public Accounting Firm
We consent to the reference to our firm under the caption “Experts” in the Registration Statement on Form F-10/A and related prospectus of Canadian Pacific Railway Company and Canadian Pacific Kansas City Limited (“CPKC”) for the offer for sale of debt securities to be issued by Canadian Pacific Railway Company and guaranteed by CPKC, and to the incorporation by reference therein of our reports dated February 27, 2025 with respect to the consolidated financial statements of CPKC as at December 31, 2024 and 2023 and for the three years ended December 31, 2024 and the related financial statement schedule, and with respect to the effectiveness of internal control over financial reporting as of December 31, 2024 included in CPKC’s Annual Report on Form 10-K filed with the Securities and Exchange Commission.
| /s/ Ernst & Young LLP |
| Chartered Professional Accountants |
| Calgary, Canada |
| March 6, 2025 |
| 1 |