WASHINGTON — The Republican-controlled Senate on Thursday approved a bipartisan bill to construct the Keystone XL oil pipeline, defying a presidential veto threat and setting up the first of many battles with the White House over energy and the environment.

The 62-36 vote advanced a top priority of the newly empowered Republicans, and marked the first time the Senate passed a bill authorizing the pipeline, despite numerous attempts to force President Obama’s hand on the issue. Nine Democrats joined with 53 Republicans to back the measure.

From Maine, independent Sen. Angus King voted against it while Republican Susan Collins voted in favor.

This bill “is an important accomplishment for the country,” said Majority Leader Mitch McConnell of Kentucky. “We are hoping the president upon reflection will agree to sign on to a bill that the State Department said could create up to 42,000 jobs and the State Department said creates little to no impact on the environment.”

The vote, however, was short of the threshold needed to override a veto, and the legislation still must be reconciled with the version the House passed.

“We hope President Obama will now drop his threat to veto this common-sense bill that would strengthen our energy security and create thousands and thousands of new, good-paying American jobs,” said House Speaker John Boehner.

Democrats framed the bill as gift to a foreign oil company that would have little benefit for the American people, because much of the oil would be exported. They tried and failed to get amendments on the bill to construct the pipeline with U.S. steel, ban exports of the oil and the products refined from it, and protect water resources.

The Senate agreed to add an energy efficiency measure, and went on the record saying climate change was not a hoax and the oil sands should be subject to a tax that helps pay for oil spill cleanups. Oil sands are currently exempt.