WASHINGTON — Senate Democrats, by a single vote, stopped legislation that would have approved construction of the Keystone XL pipeline, one of the most fractious and expensive battles of the Obama presidency.

The vote represented a victory for the environmental movement, but the fight had taken on larger dimensions as a proxy war between Republicans, who argued that the project was vital for job creation, and President Obama, who had delayed a decision on building it.

Senator Mary L. Landrieu, Democrat of Louisiana, who is facing a runoff election Dec. 6, had pleaded with her colleagues throughout the day to support the pipeline, leading to a rare suspense-filled roll call in the Senate. But she was ultimately rebuffed and fell short by one. The bill was defeated with 59 votes in favor and 41 against, and Ms. Landrieu needing 60 votes to proceed.

The vote was also a reflection of how a once-obscure pipeline blew up into a national political battle between environmentalists and the oil industry. Although the TransCanada company proposed the pipeline in 2005, it generated so little attention that Secretary of State Hillary Rodham Clinton was poised to approve it in 2011 with little fanfare.