By Allison Lampert

MONTREAL (Reuters) - Planemaker Bombardier Inc <BBDb.TO> said on Thursday it signed a long-expected deal with Quebec for the Canadian province to invest $1 billion in its CSeries aircraft program, which has struggled with years of delays and cost overruns.

The agreement leaves the Montreal-based manufacturer free to focus on talks with Canada's federal government over possible investment, a deal which is proving much harder to pull off.

Quebec and Bombardier want the federal government to match the province's investment in the narrowbody jet program. But negotiations have dragged on, with sources close to the talks saying Prime Minister Justin Trudeau's Liberal government wants changes to the plane-and-train maker's dual-class share structure.

Quebec Transport Minister Jacques Daoust told Reuters in an interview the deal contains a clause that would allow the province to match the terms of any federal investment. He also said he believes a deal with the federal government was possible despite protracted talks.

Should federal investment not materialize, Daoust said the province would not rule out a foreign investor in the CSeries. But he said Quebec would retain veto rights and conditions already negotiated by the province, like keeping Bombardier's head office in Quebec, would have to be respected.

Following the news, ratings agency Moody's changed its outlook on the company to stable from negative. But it also downgraded Bombardier's senior unsecured ratings to B3 from B2, noting a separate $1.5 billon investment by Quebec's public pension fund manager in the train unit ranks it ahead of other creditors on their claim to the unit's assets.

Bombardier said it strongly disagreed with the downgrade, and that the agency failed to recognize progress in improving its risk profile.

Bombardier said it would transfer the assets, liabilities and obligations of the CSeries program to a newly created limited partnership, in which the company will hold a 50.5 percent equity stake and Quebec the rest.

The investment will be made in two installments of $500 million, the first on June 30 and the second Sept. 1.

"We understand that the deal structure is legal from a WTO (World Trade Organization) perspective," analysts at BMO Capital Markets wrote.

Brazil and Canada have locked horns repeatedly at the WTO over the issue of government support for Embraer SA <EMBR3.SA> and Bombardier.

Bombardier said it will maintain operational control of the CSeries. The limited partnership's board will consist of five directors, three proposed by Bombardier and two by Quebec.

(Additional reporting by Vishaka George in Bengaluru and Matt Scuffham in Toronto; Editing by Tom Brown and Sandra Maler)