Senate Majority Leader Mitch McConnell (R-Ky.) walks to the Senate floor for a vote, on Capitol Hill, Thursday, Oct. 11, 2018. (AP Photo/Alex Brandon)

Endangered Senate Democrats won their freedom to campaign for next month’s midterm elections Thursday and, in exchange, Majority Leader Mitch McConnell got something he highly values — votes on 15 of President Trump’s judicial nominees.

The deal struck by the two parties on Thursday allowed the Senate to wrap up its work until after the Nov. 6 midterm elections. The hiatus comes as a relief to a cadre of Democratic incumbents who face difficult races in states that voted for Trump in 2016. McConnell (R-Ky.) had threatened to keep senators in Washington, voting on Trump’s nominees, until Election Day.

But ultimately Democrats paid McConnell’s ransom to get their incumbents back home. Under the deal, the Senate confirmed all 15 judicial nominees Thursday evening. The Senate also confirmed 21 executive-branch nominees by unanimous consent Thursday, including several assistant secretaries of state, an assistant secretary of defense and deputy administrators for the Federal Emergency Management Agency and NASA.

Three of the newly confirmed judges will sit on circuit courts; the remainder are district court judges.

Trump and McConnell can now take credit for installing 84 judges to lifetime appointments on the nation’s courts — two on the Supreme Court, 29 appellate judges on the circuit courts and 53 on the district courts.

Once all the new confirmees are sworn in, roughly one of every six circuit judges will be a Trump nominee.

The Senate deal comes less than a week after McConnell’s decision to “plow right through” opposition to Supreme Court Justice Brett M. Kavanaugh left Democrats fuming — and some liberal activists demanding that they withhold consent for any additional confirmations.

“My suspicion is, they’re not too happy after last week, but this isn’t about them being happy,” Sen. John Cornyn (R-Tex.), the No. 2 GOP leader, said before the deal was reached. “This is about the price of getting home, and particularly with a lot of Democrats running for reelection, I suspect they would like to get home.”

That ultimately proved to be the case, but as late as Thursday afternoon, Senate Democrats were still working through some internal resistance to the idea that they ought to consent to anything with Republicans — let alone more judicial confirmations.

“There’s a fair amount of residual heat” from the Kavanaugh showdown, Sen. Christopher A. Coons (D-Del.) said as he walked into a caucus lunch.

On Wednesday, several members of the liberal wing of the Democratic caucus indicated they would play no part in any deal to accelerate additional Trump nominees. And under Senate rules, accelerating anything requires the consent of all 100 senators.

Sen. Cory Booker (D-N.J.), for instance, said he wanted “regular order” for all Trump-nominated judges — shorthand for a process that could eat up more than a day of floor time per nominee.

But by Thursday other liberals — mindful of the political reality faced by their red-state colleagues — were striking a more moderate tone.

“The fact of the matter is, we don’t have the votes to stop these nominees,” said Sen. Mazie Hirono (D-Hawaii). “I do know that the elections matter, and I’d like to enable my colleagues to go home, and every day that goes by that they’re not touching base with their constituents is not a good thing.”

Any one senator could have scuttled the deal reached Thursday.

Vanita Gupta, president of the Leadership Conference on Civil and Human Rights, blasted senators Thursday for “jamming through” Trump nominees without running through all of the debate time available under Senate rules.

“Turning the Senate into a rubber stamp for Trump’s takeover of our courts is appalling,” she said in a statement. “Our courts matter far too much to rush this process.”

A senior Democratic aide, who spoke on the condition of anonymity to describe internal deliberations, said the 15 judges confirmed Thursday fell short of the total number of judges McConnell might have confirmed had he kept the Senate in session through Election Day. Before the day’s action, more than 40 judges sat on the Senate calendar awaiting floor action.

Democrats refused to allow a vote on one particularly controversial appellate nominee, North Carolina attorney Thomas A. Farr, the aide said.

Sen. Richard Blumenthal (D-Conn.) said Democrats had “limited leverage” to force a different outcome.

“We’re in the minority,” he said. “The only way we are back in the majority is if our incumbents win.”

Facing tough races are Democratic Sens. Joe Donnelly (Ind.), Heidi Heitkamp (N.D.), Joe Manchin III (W.Va.), Claire McCaskill (Mo.), Bill Nelson (Fla.) and Jon Tester (Mont.).

McConnell appeared happy to threaten to keep those lawmakers in Washington, voting on Trump’s nominees — even though it isn’t only Democrats who are itching to get out of town.

Several Republican incumbents, including Sens. Ted Cruz (Tex.) and Dean Heller (Nev.), face tough races of their own. Cruz, facing an unusually robust Democratic challenger in Rep. Beto O’Rourke, said Thursday he had no desire to stay and vote on judges: “I’m always happier to be in Texas,” he said.

In an interview aired Thursday by NPR, McConnell said he was “increasingly optimistic” about holding the majority as the Kavanaugh fight energized Republicans by reminding GOP voters of what is at stake in the midterms.

“I think it makes a huge difference,” he said. “Lose the Senate and the project of confirming judges is over for the last two years of President Trump. That, I think, is a scary prospect to the people who like what we’ve been doing on the judge project, and I hope will help us hold on to our majority.”

Republicans hold a razor-thin 51-49 advantage.

Cornyn this week described the nominees that Republicans wanted confirmed as “not controversial,” but two of the three appeals court nominees — David Porter and Ryan Nelson — emerged from the Senate Judiciary Committee on party-line votes. The third, Richard J. Sullivan, had some Democratic support.

Seven of the 15 judges voted on Thursday were confirmed with fewer than 60 votes.

“There are some that are clearly controversial,” Sen. Richard J. Durbin (D-Ill.) said Thursday.

Trump and McConnell have put a heavy emphasis on judicial nominations — not only confirming Supreme Court justices Kavanaugh and Neil M. Gorsuch but installing more than two dozen appeals court judges in Trump’s first 21 months in office, a record pace.

That Democrats would consent to accelerating that effort infuriated liberal activists already incensed at how Republicans muscled Kavanaugh onto the bench despite allegations of sexual misconduct.

Hirono said that Democratic voters need to keep an eye on the bigger picture.

“I hope that our supporters understand that what we need to be focusing on is the outcome of the 2018 elections,” she said. “Our base needs to make sure that they and everybody else they can think of can go to the polls so that we can actually stop these nominees from getting through. Right now, we do not have those votes, and I think they understand that.”

The House, whose Republican majority is more at risk than the Senate’s, has been on recess since Sept. 28. Both chambers will reconvene in Washington on Nov. 13, where they will immediately face a lengthy to-do list topped by an early December government funding deadline — setting up a bitter partisan fight over money for Trump’s southern border wall.

Also on the agenda are potential House leadership battles in both parties, finalizing a contentious farm bill and possible consideration of the revised trade deal that the Trump administration negotiated recently with Canada and Mexico.