(Reuters) - Former President Barack Obama, back on the campaign trail on Thursday for the first time since he left the White House, called on voters to reject a growing “politics of division” that he said was corroding American democracy.

Without mentioning Republican President Donald Trump by name, Obama told campaign rallies in New Jersey and Virginia that voters could send a powerful message about the type of politics they want by backing Democrats in Nov. 7 elections in the two states.

“What we can’t have is the same old politics of division that we have seen so many times before, that dates back centuries,” Obama told a cheering crowd in Newark, New Jersey, that chanted: “Four more years.”

“Some of the politics we see now, we thought we put that to bed. That’s folks looking 50 years back,” Obama said. “It’s the 21st century, not the 19th century.”

At a later stop in Richmond, Virginia, Obama said modern politics increasingly did not reflect basic American values of inclusiveness and were driving people away from the process.

“We’ve got folks who are deliberately trying to make folks angry, to demonize people who have different ideas, to get the base all riled up because it provides a short-term tactical advantage. Sometimes that feels frustrating,” Obama said.

Many of Obama’s comments appeared to be thinly veiled swipes at Trump, whose combative style and inflammatory rhetoric have led to frequent controversy and stoked political tensions.

Slideshow ( 12 images )

Obama made the remarks just hours after former President George W. Bush, a Republican, also took an indirect swing at Trump with a speech decrying “bullying and prejudice” while defending immigrants and trade.

Obama’s appearances were aimed at driving up Democratic turnout in New Jersey and Virginia, the only two states holding elections for governor this year. Democrats hope Obama can bring some of the young, minority and infrequent voters who powered his two elections to the White House out to the polls in off-year elections.

CLOSELY WATCHED

The two contests will be closely watched to see if Democrats can convert the grassroots resistance to Trump into electoral wins after falling short earlier this year in four competitive special congressional elections.

The governor’s races, and a special election in December for a U.S. Senate seat in Alabama, could offer clues to the national political mood ahead of next year’s congressional elections, when all 435 seats in the House of Representatives and 33 of the Senate’s 100 seats will be up for grabs. Republicans currently control both chambers.

Since leaving the White House in January, Obama has frequently been forced to defend his record as Trump and Republicans have tried to gut his signature healthcare law and roll back his immigration and environmental policies.

Slideshow ( 12 images )

While he has rarely spoken out about politics in the past nine months, Obama said it was critical that supporters get their friends and families to vote.

In Newark, he said no one should assume victory just because opinion polls show Phil Murphy, a former investment banker and U.S. ambassador to Germany, has a comfortable lead on Republican opponent Kim Guadagno, the state’s lieutenant governor.

“I don’t know if you all noticed that, but you can’t take any election for granted,” he said in a reference to Democrat Hillary Clinton’s surprise loss last year in the presidential race.

In the political battleground of Virginia, polls show a close contest between Democrat Ralph Northam, the state’s lieutenant governor, and Republican Ed Gillespie, a former Republican National Committee chairman who has been endorsed by Trump.

Obama carried Virginia in both 2008 and 2012, and Democrat Hillary Clinton won the state over Trump by 5 percentage points in 2016.