WASHINGTON — A bill to force approval of the Keystone XL pipeline failed in the Senate on Tuesday, sparing President Barack Obama from having to veto legislation that several fellow Democrats supported.

The measure fell one vote short of the 60 needed for passage, despite frantic last-minute lobbying by supporters, including Democratic Sen. Mary Landrieu of Louisiana, who faces a runoff election on Dec. 6. She has staked her hopes of winning on the Keystone gambit.

The tally was 59-41 on Keystone, which would carry more than 800,000 barrels of oil per day from Alberta to Nebraska, en route to the Gulf of Mexico. All 45 Republicans supported it.

Construction workers, unions and energy companies say it would create thousands of jobs. But many environmentalists oppose the project, saying development of the oil sands would spike carbon emissions linked to climate change and that the oil could be sold abroad.

Keystone supporters in the Senate faced tough odds, and one lawmaker they hoped might be a “yes” — independent Sen. Angus King of Maine — voted against the project.

In a news release earlier Tuesday announcing he would vote against the bill, King said, “Congress is not — nor should it be — in the business of legislating the approval or disapproval of a construction project.”

King, who often votes with Democrats, had been seen as a possible swing vote despite his support of climate activism. He said he was “frustrated” by Obama’s failure to make a decision on the pipeline that has been pending for six years and urged the president to make a decision soon.

Voting in favor of the bill, Sen. Susan Collins of Maine said in a statement, “I would much rather see our nation receive and refine the oil from our close ally than have it shipped overseas to Asia. Canada is our nation’s largest trading partner, and this pipeline, constructed at the highest safety standards, would create thousands of jobs in our two nations — both in building the pipeline and in the refining of crude oil, one reason why many labor unions support its construction.

“More than six years ago,” she said, “TransCanada’s application for a permit was filed with the U.S. State Department to build the Keystone XL pipeline. … The environmental reviews and studies have been completed, and it is past time for the president to have made a decision. … Moreover, if construction of the pipeline continues to be blocked, the oil would instead be moved by other modes of transportation, such as ships or trains, each of which carry their own risks for accidents, spills, and harmful emissions.”

Obama opposed the Keystone bill and wants the State Department to finish its review of the pipeline. He has said he would not approve the pipeline if it significantly raised greenhouse gas emissions.

Had the bill passed, Obama was widely expected to have vetoed it, a power he has used only three times in six years. He raised new questions about the project during a trip to Asia late last week, saying it would not lower gas prices for drivers but would allow Canada to “pump their oil, send it through our land, down to the Gulf, where it will be sold everywhere else.”

Republican Sen. Mitch McConnell of Kentucky, who will become Senate majority leader in January after his party made big gains in this month’s midterm elections, said after the vote that consideration of a Keystone bill would be “very early up” in the next Congress.

Republican Sen. John Hoeven of North Dakota, who co-sponsored the Keystone bill with Landrieu, has pledged to keep trying to force approval of the project that the administration has kept under review for more than six years. Hoeven may introduce a new bill in January or February, or he could attach a Keystone measure to a broader bill that Obama would find difficult to veto.