Nancy Pelosi, the only female US Speaker of the House, was re-elected Sunday as House speaker with a narrow majority in a deeply divided new Congress that convened in the final weeks of Donald Trump’s presidency.

Pelosi, an 80-year-old lawmaker from California, faced a scare when five fellow Democrats voted “present” or for someone else during the floor vote.

However, the woman who has led the Democratic caucus for several years secured her fourth non-consecutive term as House speaker with a vote of 216 for her against 209 for the Republican leader Kevin McCarthy.

Before the vote, Pelosi and her allies had projected confidence that she would win reelection.

In a symbolic gesture, McCarthy formally handed over the gavel to Pelosi, AFP reported.

“We begin the new Congress during a time of extraordinary difficulty,” Pelosi told the chamber, noting the toll of 350,000 dead and 20 million infected by COVID-19.

“Our most urgent priority will continue to be defeating the coronavirus,” a masked Pelosi said, AFP reported. “And defeat it, we will.”

Pelosi has been Trump’s chief nemesis in Congress, and the two clashed bitterly over the past two years, particularly as she levelled impeachment charges against the president.

Trump was impeached in December 2019, but the Senate acquitted him early in 2020. His successor, Joe Biden, takes office on January 20.

With Pelosi scrambling to keep her post, it was a handful of progressive lawmakers or members-elect who have been critical of her leadership but ultimately voted for her on Sunday.

Among them were Alexandria Ocasio-Cortez, one of the most high-profile Democrats in Washington, and incoming lawmaker Cori Bush, who is the first African-American woman to represent Missouri in Congress.

There are normally 435 seats in the House, but just 427 votes were cast Sunday as a few congressmen-elect are in quarantine due to COVID-19 and a tight House race in New York has yet to be formally decided.

One congressman-elect from Louisiana, Luke Letlow, died of complications from Covid-19 last week, days before he was due to be sworn in.

That leaves Democrats with one of the slimmest House majorities in recent decades, 222 to 211 with two vacancies.