WASHINGTON — Representative Nancy Pelosi clinched the votes for a second stint as House speaker on Wednesday after agreeing to serve no more than four years in a deal with a group of Democratic rebels — a concession to their demands for generational change.

The group of insurgents, including US Representative Seth Moulton of Salem, wanted new blood in the top Democratic ranks and maneuvered for months to deny Pelosi, a California Democrat, the votes she would need to trigger a shake-up. After weeks of behind-the-scenes negotiating, Pelosi backed off her resistance to setting a date for her departure but avoided becoming an immediate lame duck.


‘‘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 said in a statement.

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.

A spokesman for Moulton confirmed that he would vote for Pelosi as speaker. In a statement issued Wednesday evening, Moulton offered mild praise for Pelosi after what he called a “contentious process’’ that led to the agreement.

“My goal has been to have party leadership that reflects the new generation of Democrats in our country and represents the people who voted for change on election day. With the agreed-upon measures, we will do that,’’ Moulton said.

“Now it’s time to move forward as one. Nancy Pelosi showed real leadership by agreeing to these reforms. But there’s also a lesson in all of this: tough conversations make us stronger, not weaker, and we need to keep having them if we’re going to deliver on the change that we’ve promised the American people,’’ he said.


In recent weeks, Moulton has publicly rebuked Pelosi, saying at one point he was “100 percent” sure she could be defeated. Moulton’s Pelosi opposition has fueled speculation that he would face a primary challenge in the Sixth Congressional District in 2020.

Under the accord, Pelosi, 78, will support a three-term limit for the top three 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 Hoyer, a Maryland Democrat, and incoming House majority whip James Clyburn, a South Carolina Democrat — 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.

Already the first woman to serve as speaker, Pelosi would cement her place in history by joining 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 taken the gavel back after more than four years out of power.

Pelosi appeared to solidify her standing Tuesday during an Oval Office meeting with President Trump. For 17 televised minutes, Pelosi and Senate minority leader Charles Schumer, a New York Democrat, sparred with Trump over his desire for US-Mexico border wall funding, a clash that highlighted the stakes of the speakership race.


One person familiar with the talks said the incumbents, running in safe Democratic districts, want to ‘‘give cover’’ to freshmen in more marginal districts who want to stick to pledges they made during their campaigns 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 — but Pelosi has agreed to abide by the limit regardless.

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

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

The terms of the deal were hashed out Tuesday afternoon just hours after Pelosi left the White House.

Danny McDonald of the Globe staff contributed to this report.