OTTAWA—The Canadian government said on May 29 it will buy Kinder Morgan Canada Ltd.’s Trans Mountain pipeline project for $3.46 billion but does not intend to be the long-term owner of the project, which has faced fierce environmental opposition.

Canada will also offer federal loan guarantees to ensure construction continues through the 2018 season as part of the deal with the company, a unit of Houston-based Kinder Morgan Inc. (NYSE: KMI).

“The federal government has reached an agreement with Kinder Morgan to purchase the existing Trans Mountain pipeline, and infrastructure related to the Trans Mountain expansion project,” Finance Minister Bill Morneau told reporters.

“So our message today is simple: 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,” he said.

The company had set a May 31 deadline to decide if it would proceed with the expanded line from Edmonton, Alberta, to a port in the Vancouver area, which would give landlocked Canadian crude greater access to foreign markets.

Kinder Morgan set the deadline in part due to frustrations with delays caused by the British Columbia government, which is concerned about possible oil spills.