Exhibit 23.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-4 of Canadian Pacific Railway Limited and Canadian Pacific Railway Company for the offer to exchange notes issued by Kansas City Southern for notes to be issued by Canadian Pacific Railway Company and guaranteed by Canadian Pacific Railway Limited, and to the incorporation by reference therein of our reports dated February 24, 2023 with respect to the consolidated financial statements of Canadian Pacific Railway Limited as of and for the year ended December 31, 2022, and with respect to the effectiveness of internal control over financial reporting as of December 31, 2022 included in its Annual Report on Form

10-K filed with the Securities and Exchange Commission.

/s/ Ernst & Young LLP

Chartered Professional Accountants

Calgary, Canada

March 20, 2023