(Adds comments by prime minister, stock closing lower, details of proposed purchase)
By David Ljunggren and Rod Nickel
OTTAWA/WINNIPEG, May 29 (Reuters) - Canada will buy Kinder Morgan Canada Ltd's Trans Mountain pipeline for C$4.5 billion ($3.5 billion), the government said on Tuesday, hoping to save a project that faces formidable political and environmental opposition.
Finance Minister Bill Morneau said purchasing the pipeline was the only way to ensure that a planned expansion could proceed. The pipeline, running from the oil sands of Alberta to a port in the Pacific province of British Columbia, would allow Canadian crude to gain greater access to foreign markets and higher prices.
Kinder Morgan Canada gave Ottawa until May 31 to come up with reassurances it could press ahead with plans to more than double the capacity of the existing pipeline amid efforts by British Columbia to block construction.
The company also faced opposition from environmentalists and aboriginal groups who worried about the pipeline spilling its tar-like heavy oil.
"When we are faced with an exceptional situation that puts jobs at risk, that puts our international reputation on the line, our government is prepared to take action," Morneau told reporters.
He said the pipeline purchase provided the federal jurisdiction needed to overcome British Columbia's opposition, but gave no details of how this would work.
The federal government can in theory step in and disallow any provincial laws that British Columbia might use to block the pipeline, but this provision in the Canadian constitution has not been used since the 1940s.
Ottawa could also deploy the police and troops to maintain a barrier between protesters and construction workers.
Although Ottawa has taken stakes in struggling energy projects, Tuesday's announcement marked the first time Ottawa has bought an entire pipeline. It does not intend to own the project for long.
"There is a very strong business case for this pipeline," Prime Minister Justin Trudeau told Bloomberg Television, saying the government takeover meant "a lot of the legal barriers and a lot of the challenge points actually disappear".
Kinder Morgan Canada shares initially jumped as much as 8.5 percent before ending down 3 percent, while the broader Canada share index fell 0.6 percent.
The move drew immediate criticism from both sides of the political spectrum, and could hurt Trudeau's popularity in the key British Columbia battleground in a 2019 federal election.
The decision represents "a massive, unnecessary financial burden on Canadian taxpayers," Canadian Taxpayers Federation Federal Director Aaron Wudrick said.
The government will also offer federal loan guarantees to ensure construction of the expansion continues through the 2018 season as part of the deal with the company, a unit of Houston-based Kinder Morgan Inc.
Morneau sidestepped questions about how Ottawa will deal with opposition from environmentalists and aboriginal groups, who cite the risk of a catastrophic spill.
"It's a mess out there," said a Calgary industry source not authorized to speak publicly. "Given it will be stuck in court for a while, I don't think we will see this pipe built anytime soon."
Morneau said more spending would be needed to complete the expansion, but gave no precise financial details, and stressed he felt the project should be returned to the private sector.
Canada's oil sector has been stung in the past year as foreign energy companies retreated amid concerns about the environmental toll, high production costs and a risky regulatory regime.
"We have agreed to a fair price for our shareholders," said Steve Kean, chief executive officer of Kinder Morgan Canada and Kinder Morgan Inc.
Kean did not say why he decided to sell rather than absorb the risk of further delays. Kinder Morgan Canada will continue to own the remaining assets, including crude storage, rail terminals and a condensate pipeline, and look to expand.
"I think the transaction is a win-win. It's actually better for Kinder Morgan than it is for Canada. They are getting a very good value," said Paul Bloom at Bloom Investment Counsel Inc, which owns about 300,000 shares in Kinder Morgan Canada.
The fact the federal government needed to buy Trans Mountain to ensure the project goes ahead does not bode well for the industry, said Chris Bloomer, CEO of the Canadian Energy Pipeline Association.
Trans Mountain stirred an unusual public fight between neighboring provinces. Alberta threatened to halt crude and fuel shipments to British Columbia, where consumers already pay high gasoline prices, and briefly halted imports of the coastal province's wines.
Alberta will contribute up to C$2 billion toward unforeseen costs, payable once the project is complete, Premier Rachel Notley said. The contribution will convert into equity in the pipeline.
British Columbia Premier John Horgan said the province would push ahead with a court case to establish its right to restrict increased shipments of crude oil to its coastal waters.
Reporting by David Ljunggren in Ottawa and Rod Nickel in Winnipeg Additional reporting Leah Schnurr in Toronto, Nicole Mordant in Vancouver and Nivedita Bhattacharjee in Bangalore; Writing by Andrea Hopkins, David Ljunggren and Rod Nickel; Editing by Denny Thomas, Jeffrey Benkoe and Lisa Shumaker