Mr. Trudeau has been trying to avoid taking the path of his father, Pierre Elliott Trudeau, whose energy policies as prime minister in the 1980s deeply soiled the family name among Albertans. The elder Mr. Trudeau imposed extra taxes and royalties along with price controls that angered the province’s oil industry. The younger Mr. Trudeau spoke up swiftly on Tuesday, welcoming Mr. Trump’s action. And the Canadian leader’s public support for the energy industry has helped him sell his national carbon-pricing program in the province — a program that polls strongly in areas away from the oil patch, especially Ontario and British Columbia.

But now people on all sides are angry at him. Along with a decision in late November to approve two other pipeline projects, Mr. Trudeau’s welcome of the Keystone XL revival has alienated many environmentalists in Canada, and has also strained his relations with some indigenous communities affected by the pipelines. And hours after Mr. Trump’s move was announced, Mr. Trudeau found himself in a heated public exchange in Calgary, Alberta, with a supporter of the oil sands.

“The federal government now has to be able to demonstrate that its climate plan is still relevant with increased oil-sands production,” said Simon Dyer, the regional director for Alberta at the Pembina Institute, an environmental group that accepts Mr. Trudeau’s argument that the oil sands are vital to the economy. “When you start to stack up the potential for increased production from increased pipeline capacity, it strains credibility that oil-sands emissions targets will be met.”

Dennis McConaghy, a former executive at TransCanada, the company that proposed Keystone XL, said he welcomed both Mr. Trump’s move and Mr. Trudeau’s endorsement of the project. But he agreed with Mr. Dyer that building the pipeline might make it impossible for the government to meet its emissions targets.

“The country needs to find a balance between a credible carbon policy and seizing this economic opportunity,” said Mr. McConaghy, who recently published a book on Keystone XL. “But on carbon, they have outlined commitments which will be very challenging to meet, especially given increased oil sands production.”