Exhibit 5.1

KPMG LLP
PO Box 10426 777 Dunsmuir Street
Vancouver BC V7Y 1K3
Canada
Telephone (604) 691-3000
Fax (604) 691-3031
Consent of Independent Registered Public Accounting Firm
The Board of Directors
Westport Fuel Systems Inc.
We, KPMG LLP, consent to the use of our report dated March 13, 2023, on the consolidated financial statements of Westport Fuel Systems Inc., which comprise the consolidated balance sheets as of December 31, 2022 and December 31, 2021, the related consolidated statements of operations and comprehensive income (loss), changes in shareholders’ equity and cash flows for each of the years in the two-year period ended December 31, 2022, and the related notes, and our report dated March 13, 2023 on the effectiveness of internal control over financial reporting as of December 31, 2022 which are incorporated by reference, and to the reference to our firm under the heading “Auditors” in the final short form base shelf prospectus.
/s/ KPMG LLP
Chartered Professional Accountants
May 18, 2023
Vancouver, Canada
KPMG LLP, an Ontario limited liability partnership and member firm of the KPMG global organization of independent member firms affiliated with KPMG International Limited, a private English company limited by guarantee. KPMG Canada provides services to KPMG LLP.