Rep. Nancy Pelosi cut a deal with Democratic rebels Wednesday to clinch the votes for a second stint as House speaker. Conceding to their demands for generational change, Pelosi agreed to serve no more than four years.

The deal was a capstone to a remarkable 48 hours for Pelosi, who sparred with President Trump on Tuesday at the White House over his demand for U.S.-Mexico border wall funding. She challenged the Republican president and explained the legislative process to him — a clash that highlighted the stakes of the speakership race and Pelosi’s bid to be the most powerful woman in American politics.

For months, a group of insurgents maneuvered to deny Pelosi the necessary votes, calling for new blood in the top Democratic ranks. After weeks of behind-the-scenes negotiating, Pelosi eased off her resistance to setting a date for her departure.

“Over the summer, I made it clear that I see myself as a bridge to the next generation of leaders, a recognition of my continuing responsibility to mentor and advance new members into positions of power and responsibility in the House Democratic Caucus,” Pelosi (D-Calif.) said in a statement.

The response was swift — almost immediately, seven Democratic holdouts said they would back Pelosi. Their support would be enough to secure the House majority that she needs for her election to speaker on Jan. 3 — 218 votes if all members are present and voting for an individual.

According to a Washington Post analysis, that would leave Pelosi with no more 16 Democrats openly opposing her. She could weather as many as 17 defections if all members are voting.

Already the first woman to serve as speaker, Pelosi is on the path to join a small group of lawmakers who regained the speakership after losing it. She would be the first speaker to do so since Texas Democrat Sam Rayburn took the gavel back in 1955. No other two-time speaker has reclaimed the gavel after more than four years out of power.

Hammering out terms of the deal

Hours after the Tuesday White House session, Pelosi hashed out the final terms of the deal in her Capitol Hill office with Democratic Reps. Bill Foster (Ill.), Ed Perlmutter (Colo.) and Linda T. Sánchez (Calif.). Over the following day, those members relayed the deal back to fellow colleagues opposing Pelosi and honed the final announcement.

Besides those three members, Reps. Seth Moulton (D-Mass.), Tim Ryan (D-Ohio) and Filemon Vela (D-Tex.), as well as Rep.-elect Gil Cisneros (D-Calif.) said Wednesday that they would back Pelosi.

“We are proud that our agreement will make lasting institutional change that will strengthen our caucus and will help develop the next generation of Democratic leaders,” they said in a joint statement. “We will support and vote for Nancy Pelosi for Speaker of the House in the 116th Congress.”

Under the accord, Pelosi, 78, will back a three-term limit for the top four House Democratic leaders, with a possible fourth term if Democratic members vote by a two-thirds majority to retain them.

The limit would be retroactive, meaning Pelosi, incoming House Majority Leader Steny H. Hoyer (D-Md.), incoming House Majority Whip James E. Clyburn (D-S.C.) — all of whom held the same posts from 2007 to 2011 — would be effectively limited to one, maybe two, terms going forward if the policy is adopted. The term limit would also apply to Rep. Ben Ray Luján (N.M.), who is poised to assume the No. 4 job.

“I am comfortable with the proposal and it is my intention to abide by it whether it passes or not,” Pelosi said.

The vote on term limits would occur by Feb. 15.

In addition to the term-limits proposal, Pelosi agreed to set up a “leadership development program” open to members who are interested in moving up the caucus’s ranks. The rebels also said Pelosi had agreed not to retaliate against those who had opposed or will continue opposing her. The Pelosi aide disputed that such an assurance was necessary: “She didn’t agree not to retaliate, because she doesn’t retaliate.”

Pelosi struck the deal to get “the biggest vote possible and to have as much unity as possible,” said an aide to the leader who was not authorized to comment publicly on the discussions. Absent a deal, the speaker race might have gone to the House floor unsettled, setting up a messy fight.

Political clashes

No Democrat had announced a challenge to Pelosi; her critics envisioned a scenario in which they would deny Pelosi the votes needed on the House floor, touching off a scramble for an alternative.

But the lack of a viable alternative hamstrung the rebels, and as Pelosi leaned on a vast network of political allies to promote her return as speaker, many of her opponents experienced a fierce political backlash.

Moulton, for instance, is facing a potential primary challenge in 2020. He said in a statement that the “conversations have been difficult, but we’re stronger because of them.”

“The leaders of our caucus will no longer be determined by tenure and loyalty but by frequent and open elections, giving us a better chance to change and evolve as the country does,” he said, praising Pelosi for having “showed real leadership by agreeing to these reforms.”

Several freshmen and a handful of incumbents are still expected to oppose her. At least two sitting members critical of Pelosi, Reps. Kathleen Rice (D-N.Y.) and Kurt Schrader (D-Ore.), said this week they will oppose Pelosi regardless of any vow to step aside in the future.

One aide to a member who participated in the talks said the incumbents — running in safe Democratic districts — wanted to “give cover” to freshmen in more marginal districts who want to stick to campaign pledges and vote against Pelosi without actually blocking her from the gavel.

Pelosi was nominated as speaker by House Democrats last month on a 203-to-32 vote, but many of the Democrats vowed to oppose her in the decisive floor vote if she did not make further concessions, prompting the negotiations.

The term-limit proposal is subject to a vote of House Democrats next year — one that could very well become contentious, with Hoyer and Clyburn expected to oppose it. The limits would not extend to committee chairmen, a contentious proposal that could have sparked political warfare among House Democrats.

Hoyer told reporters Tuesday that he was not for term limits of any sort, dismissing Pelosi’s discussions: “She’s not negotiating for me.”

“I have a term limit — it’s a two-year term limit,” he said, referring to the length of a House term. “I am not for term limits. I am for the intellect of the voter, whether it’s my constituency or my colleague being able to operate without such constraint and choose who they want when they want.”

Kamala Harris attended a black university in a black city. But she grew up in a mostly white world.

When anyone challenges her racial identity, the presidential candidate points to her four years at Howard University

Democratic presidential candidates’ new target? Elizabeth Warren.

Joe Biden has been leading the new critique of Warren by raising questions about her ‘candor’

Transportation Secretary Elaine Chao faces House Oversight Committee investigation over ethics allegations

The committee sent Chao a letter with 18 requests for documents and information