Sen. John McCain (R-Ariz.) is getting credit for reaching across the aisle to help avert a Senate showdown. (Jahi Chikwendiu/WASHINGTON POST)

After more than three hours of talking, senators began filtering out of the Old Senate Chamber, still without a path to avoiding a showdown on controversial rules changes. But Sen. John McCain (R-Ariz.) had a few last words for four Democratic leaders huddled in a corner.

“We’ve got to find a way to get this done,” McCain told Senate Majority Leader Harry M. Reid (D-Nev.) and his leadership team, according to a Democrat listening to the conversation.

With that, the 2008 GOP presidential nominee began a final frenzy of negotiations that resulted in Tuesday’s deal to secure the confirmation of nominees for his onetime rival, President Obama, while keeping Reid from deploying an unprecedented party-line maneuver to change filibuster rules.

It also cemented the return of the self-proclaimed “Maverick McCain,” who spent most of his Senate career as a freewheeling dealmaker with a penchant for irritating GOP leaders and lacerating those who crossed him. In the past six months, McCain has been at the center of two big bipartisan deals to avert showdowns over proposed filibuster changes and, just last month, he ushered a comprehensive immigration overhaul across the Senate floor with 68 votes.

McCain, 76, has assumed the mantle of the “Old Bulls” who have departed the Senate in the past decade, powerful committee chairmen like the late Edward M. Kennedy (D-Mass.) and John W. Warner (R-Va.), who retired in January 2009.

Nothing better captured this as well as the whirling tide of emotion and the soaring words of praise for McCain as Reid announced the deal.

“John McCain is the reason we’re at the point we are,” Reid said, adding that the senator from Arizona acted “at his own peril.”

Just five years ago, in the heat of the Obama-McCain campaign, the majority leader publicly declared “I can’t stand John McCain,” while also questioning his temperament to be president. A decade ago McCain was still feuding with Minority Leader Mitch McConnell (R-Ky.) because of the eponymous campaign finance law that McConnell filed a federal lawsuit against to try to overturn.

Yet in recent years McConnell has appointed the former Vietnam prisoner of war as the GOP caucus’s de facto leader on national security issues.

The key to this strategy was trust, McCain said Tuesday. “You just build up some trust with people, they trust your word, they trust your confidence.”

That, and building up his cellphone’s battery, as McCain twice drained the power on his device in late-night phone calls Monday. One conversation with his newest bargaining partner, Sen. Charles E. Schumer (D-N.Y.), prompted him to just plug the device into its charger and keep talking.

Democrats said that McCain’s role showed McConnell’s diminished power over his caucus, saying that Reid and Schumer dealt almost exclusively with the Arizona senator and repeatedly rebuffed McConnell’s offers of a different framework for a deal. Schumer said McConnell had been searching for a deal that would have allowed the confirmation of controversial nominees to run the Consumer Financial Protection Bureau and the National Labor Relations Board, if Reid swore off any intention to use a party-line vote to limit filibusters through 2014.

Reid balked at that offer, in front of other senators at Monday night’s marathon closed-door session and in two private meetings with the GOP leader, according to a senior Democratic aide.

Instead, the Democrats focused on McCain, who insisted in interviews Tuesday that he was not undercutting McConnell. He said both leaders face “restive members” among a large flock of junior senators, making their jobs more difficult than their predecessors, and that he is just trying to help where he can.

McCain said he went out of his way the past few days to keep McConnell up to speed on his dealings with Reid and Schumer. By Tuesday afternoon, McConnell pronounced himself content with McCain’s work.

“It’s a step in the right direction,” he said.

The deal did not come easy, and McCain told The Washington Post last Friday morning it was a 50-50 prospect that a deal could get done. He focused his work predominantly on senators who had supported last month’s immigration bill, since he had just secured 14 GOP votes for that legislation. “Phone call after phone call after phone call,” McCain said, describing his Saturday afternoon. At that point he thought a deal had been reached, but it fell apart over issues he declined to discuss.

“We hit a speed bump and had to put it back together,” he said.

He said Schumer’s negotiation skills are “very good, excellent, at getting people to do things.”

McCain met Reid on Monday afternoon in his office. Earlier this year, Reid hosted a bipartisan luncheon in McCain’s honor to celebrate the 40th anniversary of his release from Vietnam, a gesture that McCain deeply appreciated and still talks about.

Still, there was no deal and prospects appeared bleak heading into the gathering of the entire Senate on Monday evening. One by one, roughly three dozen senators spoke out in private, and it became clear to McCain that there were few people who wanted to see the Senate taken to the partisan brink.

“It created some goodwill,” he said.

McCain retreated to his office and began another round of phone-call diplomacy, including calling Reid repeatedly, as he huddled with Schumer and Sens. Richard J. Durbin (D-Ill.) and Patty Murray (D-Wash.).

The final piece came together when McCain told Reid that the White House could essentially name any two new picks for the NLRB — dropping the two contested nominees in front of the Senate — and they had a deal. Democratic leaders called Richard Trumka, president of the AFL-CIO, and by 9 a.m. Tuesday they had reached a deal.

Despite their strained relations, Reid and McCain entered the House together in 1983 and won Senate seats in 1986, building up three decades of shared experience. “Sometimes he says things in the heat of the moment,” McCain said of Reid.

Reminded of his own knack for a quick temper, McCain just smiled.

“I worked with him for 31 years. And we’ve had some pretty difficult times together, but in the 31 years we’ve worked together, there is no one I have ever worked with that is more a man of his word or a person of his word than John McCain,” Reid told reporters Tuesday afternoon.

Ed O’Keefe contributed to this report.