Former US President Barack Obama has accused Republicans of threatening democracy ahead of local elections seen as a national test of President Joe Biden's popularity, as he battles hard negotiations with Congress over a massive investment plan.

Obama flew to Richmond to support Democrat Terry McAuliffe, 64, the candidate for governor of Virginia, who is competing against Republican Glenn Youngkin, 54, a supporter of former President Donald Trump, as the November polling date approaches.

In front of a few hundred enthusiastic activists who gathered at Virginia Commonwealth University in Richmond, Obama said Yongkin would eliminate teaching positions, limit access to abortion and bolster Trump's claims that the presidential election was stolen from him.

"He's accusing schools of brainwashing our children. He also said he wants to check the voting machines that were used in the last presidential election... And we're supposed to believe he's going to defend our democracy?"

The former US president saw that the United States and the world are now standing at a "turning point", and said that it was about determining the type of democracy that the next generation would inherit, warning against "a return to the chaos that caused so much damage."

He added that there is a current that practices "a policy of decadence, division and conflict."

Joe Biden won Virginia by 10 percentage points over Donald Trump in the 2020 presidential election.

The last time Republicans won a statewide vote was in 2009. But candidate Terry McAuliffe has fallen behind in the polls in recent weeks.

And Obama - who remains the most popular Democrat in the United States 5 years after leaving the White House - wanted to rally African-American voters, who are a key electorate in this southern state, especially in the Richmond area, where a statue of a troop commander was removed last month. In the Civil War, General Robert Lee had become one of the focus of the anti-apartheid protests.