Former US president Barack Obama assailed President Donald Trump and Republicans on Friday, urging Democrats to deliver a check on the administration's "abuses of power" and restore a sense of sanity to politics by voting in November's elections.

In an unusually blistering attack on his successor, Obama said Americans were living in dangerous times and accused Republicans of threatening democracy, dividing the country, undermining global alliances and cozying up to Russia, Reuters reported.

"In two months we have the chance, not the certainty, but the chance to restore some semblance of sanity to our politics," he said in a speech at the University of Illinois at Urbana-Champaign. "There is actually only one check on bad policy and abuses of power, and that's you and your vote."

Both parties are urging their core supporters to get to the polls for the Nov. 6 midterm elections, when Democrats need to pick up 23 seats in the House of Representatives and two seats in the Senate to gain majorities in Congress and slam the brakes on Trump's agenda.

Obama, who had frustrated some Democrats by keeping a relatively low profile since leaving office in January 2017, accused Republicans of being unwilling to safeguard democracy or offer a check on Trump's policies or worst instincts.

He said voters would have to do it instead.

"In the end, the threat to our democracy doesn't just come from Donald Trump or the current batch of Republicans in Congress," he said. "The biggest threat to our democracy is indifference. The biggest threat to our democracy is cynicism."

Trump was dismissive of Obama's speech.

"I'm sorry, I watched it but I fell asleep," he said during a fundraiser in North Dakota. "I found that he's very, very good for sleeping."

The November elections have been seen as a referendum on Trump, who has fulfilled campaign promises to cut taxes and regulations but who faces a widening special counsel probe of Russia’s aleadged interference in the 2016 presidential election and growing questions about his fitness for office, even by some within his administration.

Obama ridiculed Trump for taking credit for economic gains that began under Obama's administration, and said Trump was exploiting cultural fears and economic anger that have grown in recent years amid societal upheavals.

"It did not start with Donald Trump. He is a symptom, not the cause," Obama said. "He's just capitalizing on resentments that politicians have been fanning for years."

Until now, Obama had been reluctant to criticize his successor publicly, although last week he appeared to chide Trump, without naming him, in a eulogy for the late Republican Senator John McCain.

But he dropped that political reticence in Illinois, the state where he launched his own political career, saying a vote against Republicans could restore "honesty and decency and lawfulness" to government.

"If you thought that elections don't matter, I hope these last two years have corrected that impression," he said. "The politics of division and resentment and paranoia has unfortunately found a home in the Republican Party."