Updated

The Senate voted in dramatic fashion Wednesday to approve one of President Obama's nominees. For Democrats to prevail, all it took was a last-ditch vote switch by one senator, a flight back from North Dakota by another and an afternoon roll call that stretched into the evening.

Five hours after the balloting started, the Senate voted to end Republican delaying tactics against B. Todd Jones, Obama's pick to head the Bureau of Alcohol, Tobacco, Firearms and Explosives. It then voted in a comparatively instantaneous 29 minutes for his final confirmation, 53-42.

A defeat would have been a setback for Obama, who is trying to plug gaps in his second-term administration's lineup, and dealt a blow to the recent cooperation between the two parties over allowing votes on the president's nominees.

The lengthy roll call and the theatrics accompanying it nearly obscured that Jones' approval marked a rare congressional victory for gun-control forces. His confirmation came three months after the Senate rejected Obama's drive to expand background checks for firearms buyers.

In a written statement, Obama applauded senators of both parties for confirming ATF's first director in seven years -- gridlock, he said, caused by Senate Republicans who "put politics ahead of the agency's law enforcement mission."

Republicans have said Obama showed no urgency, waiting until November 2010 -- almost two years after taking office -- before naming his first nominee for the ATF, Andrew Traver, whom the Senate never acted on.

Obama nominated Jones weeks after the December massacre at an elementary school in Newtown, Conn., that killed 20 first-graders and six staffers. Jones, a former Marine, has been acting ATF director since 2011.

Gun control advocates backed Jones' nomination, saying he would strengthen an agency long weakened by congressionally imposed restraints. With a national registry of gun owners forbidden by federal law, authorities face constraints when they want to trace firearms used in crimes.

For most of Wednesday afternoon, the Senate idled in neutral waiting for Sen. Heidi Heitkamp, D-N.D., to fly back from her home state, where aides said she had taken ill. She then cast the 60th vote needed to end a GOP procedural blockade aimed at derailing Jones' nomination.

But to get the 59th vote, Democrats earlier had to persuade Sen. Lisa Murkowski, R-Alaska, to switch her initial vote.

In a prolonged spectacle played out largely in full view on the Senate floor, Democratic senators swarmed around Murkowski after she at first voted to support her party's delaying tactics.

As the Senate Judiciary Committee chairman, Sen. Patrick Leahy, D-Vt., and other Democrats tried persuading her to switch, Republican senators joined the group, urging her not to change. More than a dozen lawmakers spent nearly an hour imploring Murkowski, first on the Senate floor and then in a private cloakroom.

She finally emerged from cloakroom and switched her vote.

She said in a written statement that she switched her vote after learning that Jones no longer was under investigation, as opponents had said he was, for his performance as U.S. attorney for Minnesota. She later voted against his confirmation.

Sen. Amy Klobuchar, D-Minn., who was in the middle of the crowd surrounding Murkowski, said Democrats also argued that blocking a vote on Jones "would have disrupted the relative and recent comity in the Senate."

With an autumn of fights over the budget and other issues coming up, "The last thing we want to do is leave with some radioactive blowup," Klobuchar said. Congress is due to leave for a five-week summer recess this weekend.

Most Senate roll calls take about 20 minutes.

The Senate Historian's Office said that while it lacked exhaustive data on the longest-lasting Senate roll calls, the chamber's 2009 vote on Obama's economic stimulus package lasted five hours and 15 minutes. It ended when Sen. Sherrod Brown, D-Ohio, returned from a family funeral in Ohio to vote.

Many congressional Republicans have been harshly critical of the ATF, especially for its fumbled Fast and Furious Operation aimed at gun-smuggling across the Southwest border. Sen. Charles Grassley, R-Iowa, and others have also complained that Jones' nomination should not move forward because of whistle-blower complaints against Jones involving his work as U.S. attorney for Minnesota.

Five other Republicans also voted Wednesday to end the blockade against Jones.

They included Sen. Kelly Ayotte, R-N.H., who came under pressure at home from gun control supporters after she opposed wider background checks in April. Ayotte, like Murkowski, voted against Jones' confirmation.

When Obama nominated Jones, he seemed to face long odds for winning approval. But the politically potent National Rifle Association said this week that it was neutral about Jones, which even critics of Jones conceded was important.

Senators had planned to vote Wednesday to confirm Samantha Power to become ambassador to the United Nations. That roll call was postponed until Thursday.