Speaker Nancy Pelosi, the face of House Democrats for two decades and the first woman to serve in the post, announced Thursday that she would leave leadership in January following narrow election losses that cost Democrats their majority, but will remain in Congress.

Pelosi, the Californian who twice led Democrats to power in the House and has been a central figure in the major legislative accomplishments of the Obama and Biden administrations, announced her plans in a midday floor speech on the House floor, a day after Republicans clinched control of the chamber.

“For me the hour has come for a new generation to lead the Democratic caucus that I so deeply respect,” she said. “And I am grateful that so many are ready and willing to shoulder this awesome responsibility.”

Her remarks set off a rapid and long-anticipated shift in the top ranks of Democratic leadership — now dominated by a trio of octogenarians — toward a younger group that has been waiting in the wings.

Shortly after Pelosi, 82, concluded her remarks, Rep. Steny Hoyer of Maryland, the 83-year-old majority leader, said in a letter to his colleagues that he, too, would refrain from seeking a leadership position in the next Congress. He endorsed Rep. Hakeem Jeffries of New York, 52, to be the next Democratic leader, throwing his support to a lawmaker who is widely regarded as Pelosi’s likeliest successor.

“I look forward to serving as a resource to him, to the rest of our Democratic leadership team, and to our entire caucus in whatever capacity I can best be of assistance as we move forward together to address the nation’s challenges,” Hoyer wrote.

Rep. Jim Clyburn of South Carolina, 82 and the No. 3 Democrat, was expected to cede the position of whip and seek to become the assistant leader, according to people familiar with the plans who spoke about them on the condition of anonymity because they had yet to be announced.

Jeffries and Reps. Katherine Clark of Massachusetts, 59, and Pete Aguilar of California, 43, were widely expected to seek the top three spots.

Pelosi’s announcement heralded the end of a historic leadership run for a woman who learned the nitty-gritty of politics from her family in Baltimore, where her father was a congressman and later mayor. She rose to prominence in California as the leader of the state party, a House member from San Francisco and finally as the determined force at the helm of House Democrats. With her in a leadership role, they challenged President George W. Bush over the Iraq War and won approval of President Barack Obama’s Affordable Care Act, her greatest legislative achievement, in 2010.

In her speech, Pelosi recounted the arc of her career — “homemaker to House speaker,” she said — as well as major legislative accomplishments. She also addressed the fragility of the nation’s democracy as she recalled the Jan. 6, 2021, attack at the Capitol, carried out by an angry mob who rejected the results of the 2020 election and President Donald Trump’s loss. But, she added, voters “stood in the breach and repelled the assault on democracy” last week by rejecting candidates who continued to cast doubt on the 2020 election.

As Pelosi closed her remarks, House members rose to give her a standing ovation. She was swarmed by colleagues kissing her on the cheek and giving her hugs, and embraced a young girl who was in the chamber for her speech — a moment reminiscent of her swearing-in as speaker, when she called all the children present in the chamber to the dais.

Pelosi’s decision came after her husband, Paul, was brutally attacked in their San Francisco home late last month by a hammer-wielding assailant who was said to have been planning to kidnap and assault the speaker herself. Nancy Pelosi and her security detail were not at home at the time.

By staying in Congress, Pelosi could remain an influence and a guide for the new generation of Democrats who are expected to rise into the senior leadership ranks with her departure from the top job.

In a statement released after Pelosi’s speech, President Joe Biden said history would remember her as “the most consequential speaker of the House of Representatives in our history.”

“There are countless examples of how she embodies the obligation of elected officials to uphold their oath to God and country to ensure our democracy delivers and remains a beacon to the world,” he said. “In everything she does, she reflects a dignity in her actions and a dignity she sees in the lives of the people of this nation.”

Pelosi was for years the focus of bitter attacks from Republicans who used her as a symbol of liberal Democratic ideology, but she was revered within the party — and earned the respect of many Republicans — for her leadership skills, steadiness in times of crisis, political acumen and, not least, a formidable ability to tap donors for hundreds of millions of dollars.

She worked her way up in the House hierarchy from the Appropriations Committee and the top Democratic slot on the Select Committee on Intelligence, where she was a critic of the Iraq War.

Pelosi pledged in 2018 to limit herself to four more years as her party’s leader, but had recently equivocated about whether she would honor that, and had been quietly gauging her support within Democratic ranks. Several of her colleagues had privately noted that Pelosi, 82, was unlikely to seek to stay in her position if she found she did not have the votes to do so, and equally unlikely to leave if she believed she had the backing to hold on.

Democrats had been frozen in place awaiting her decision before engaging in any public jockeying over who might succeed her at the helm of their caucus.

Many Democrats have argued for years that Pelosi’s exit from leadership was long overdue but, for years, few have been willing to step forward to challenge her iron grip on the caucus or risk crossing a figure who is well known for holding grudges against opponents.

Pelosi hinted at the possibility that she might step aside in interviews in recent days, but said she would not make any announcements about her future until control of the House was determined. That happened on Wednesday night.