The Senate averted a political meltdown Tuesday when Republicans agreed to confirm several of President Obama’s executive branch nominees and, in exchange, Democrats agreed to leave existing filibuster rules in place.

Senate Majority Leader Harry M. Reid (D-Nev.) and Sen. John McCain (Ariz.), the key GOP negotiator, announced the deal minutes before a scheduled vote on Richard Cordray, Obama’s choice to head the Consumer Financial Protection Bureau. The deal paved the way for Cordray, the acting director of the agency, to be confirmed in a vote Tuesday afternoon. He was nominated in July 2011, but Republicans had refused to confirm him.

Democratic frustration about Cordray and other stalled nominations led Reid to threaten to alter the Senate’s filibuster rules, which allow for unlimited debate unless there are 60 votes to cut it off.

Reid’s threat was to change the rules so that the nominees to executive branch agencies could be confirmed by a simple majority of 51 votes. Democrats have 54 members in their caucus.

As part of the deal, Republicans demanded that Obama withdraw his controversial nominees to the National Labor Relations Board — who had been installed through recess appointment, bypassing the Senate — but in turn guaranteed that the new selections would be confirmed.

The bottom line is that several Obama nominees will be confirmed but the Senate rules will remain unchanged — so Republicans can filibuster in the future and Reid can threaten to unilaterally change the rules again.

The compromise, and the confrontation that preceded it, dealt with some of the Senate’s most obscure parliamentary proce­dures, but together they broadly captured the partisan politics of the moment. For much of the past 20 years, each side in the minority has employed increasingly blunt tactics to slow or stall nominations and legislation advanced by the majority, often using filibusters to torpedo the majority agenda.

The number of attempted filibusters peaked in 2008, more than doubling the number from 1994, and has tapered downward since. But Democrats insist that the traditional sense of decorum in the chamber hit a nadir earlier this year when junior Republicans attempted to filibuster the nominations of national security posts that have always received overwhelming bipartisan support.

Senators suggested that the spirit of the deal and a marathon bipartisan caucus on Monday night had defused, to some extent, the increasingly hostile partisan posture the two sides had adopted over the past few months.

“I hope that everyone learned the lesson last night that it sure helps to sit down and talk to each other,” Reid said Tuesday morning. “It was a very, very good meeting.”

McCain held out hope that Monday’s rare bipartisan huddle, inside the Old Senate Chamber where key compromises of the 19th century were struck, could be a path forward on other contentious issues, such as immigration reform.

“We need to talk. We just proved that last night,” he told reporters.

Hours after the deal was announced, senators voted 66 to 34 to approve Cordray’s nomination. Twelve Republicans joined the entire Democratic caucus to approve the nominee. Other nominees considered less controversial — to lead the Labor Department, the Environmental Protection Agency and the Export-Import Bank — are expected to be confirmed by the end of the week.

The clear winner from the ugly debate was the president, who will have a full slate of his nominees confirmed and will settle the messy staffing issue at the CFPB and the NLRB. Those agencies are the subject of a legal battle that will reach the Supreme Court over Obama’s method of making an end run around Senate confirmation to install interim appointees, threatening to undermine more than 1,000 rulings issued by the labor board in the past 18 months.

The buildup to Tuesday’s deal, however, exposed the greatly deteriorated relationship between Reid and his GOP counterpart, Minority Leader Mitch McConnell (Ky.). The two men were once hailed as senators who loved the institution first, but their relationship has been in disrepair since at least the 2011 negotiations over raising the federal debt ceiling. Until now, they had kept the breakdown largely hidden.

In the past week, Reid, 73, and McConnell, 71, have dedicated hours of floor debate to excoriating each other in harsh personal terms. Even as the rest of the Senate was praising Tuesday’s deal, the two leaders’ aides tried to pin the other side’s leader as the big loser.

Democratic advisers tried to say McCain was negotiating on behalf of Republicans who had grown weary of McConnell, while Republican aides said the GOP leader told Vice President Biden three weeks ago how to resolve the NLRB dispute.

In fact, several senators said, McCain worked shuttle diplomacy from late last week until late Monday night, continually calling Reid, McConnell and other senators to shore up the deal.

Both leaders were instrumental, but left to their own, Reid and McConnell could not have reached this pact and the Senate would have gone down a path some call the “nuclear option.”

Such a treacherous relationship between the leaders leaves the Senate in a dangerous position going forward on critical legislative negotiations, particularly immigration reform and a fall showdown on another required lifting of Treasury’s debt ceiling.

Democrats predicted that the goodwill from these negotiations should at least ease the showdowns over Obama’s nominations.

“Most of us on both sides of the aisle believe that what happened in the last few days will make other presidential appointments go through more smoothly,” said Sen. Charles E. Schumer (D-N.Y.), a close Reid ally. Schumer has become an unlikely but trusted partner of McCain’s on a series of negotiations over the past seven months.

Aside from whirlwind talks led by McCain, the key moment came Monday night when Reid and McConnell convened the bipartisan caucus, which 98 of the 100 senators attended.

The meeting, which was not a leadership idea but instead came from Sen. Roger Wicker (R-Miss.), lasted 31 / 2 hours. That’s about twice the length of a normal partisan luncheon meeting that has become standard fare on a near-daily basis, where the two sides huddle in opposing rooms about 100 feet apart, gaming out legislative warfare over taxpayer-funded meals.

Senators sat interspersed with one another Monday night in the cramped quarters of a room that had grown too small for the expanding nation by 1859, listening to pleas for comity.

“People were frank. People were very frank about their concerns and needs and desires, but it was clear, everybody said. Nobody wants to come to Armageddon here,” Schumer said.

That’s what some longtime senators said a party-line vote would lead to, changing rules that have been traditionally designed to maintain the Senate as a permanent legislative body, with procedures and customs that are not privy to political winds. Formally changing a standing rule of the Senate requires 67 votes, a super-majority threshold that is otherwise reserved only for international treaties, and convicting and removing from office an impeached president.

It was the third such threat to change the rules on a partisan vote in the past 21 / 2 years, with previous standoffs ending in a public deal with McConnell. No such embrace of the two leaders came this time, and McCain and Schumer said it was the closest the Senate has come to such a rule change since a similar effort by Republicans — then in the majority — in 2005.

Republicans warned this week that if they win back the majority in the 2014 midterm elections, they will use the party-line vote to abolish the filibuster on all legislation, and then approve by a bare majority vote the repeal of Obama’s health-care law and advance anti-union legislation.

“There are too many senators who don’t understand the precedent of a Senate that can change the majority anytime it wants to, to do anything it wants to,” Sen. Lamar Alexander (R-Tenn.) warned late Monday night.

William Branigin, Jenna Johnson, Rachel Weiner and Philip Rucker contributed to this report.