RICHMOND, VA. — Former President Barack Obama took some veiled shots at President Donald Trump Thursday night, warning against the “politics of division and distraction” in his first day back on the campaign trail since Trump’s victory last November.

“We have folks who are deliberately trying to get folks angry, to demonize people with different ideas, to get the base all riled up because it provides a short-term tactical advantage,” Obama said at a rally for Virginia Lt. Gov. Ralph Northam (D), less than thee weeks until Virginia’s off-year gubernatorial election.

Obama never said Trump’s name during his mostly positive speech — but it was clear who he was talking about, taking shots at both Trump and Northam’s opponent, former Republican National Committee head Ed Gillespie.

“If you have to win a campaign by dividing people you’re not going to be able to govern them. You won’t be able to unite them if that’s how you start. Ralph Northam believes we should have an orderly immigration system, that we should crack down on criminals and gangs,” he said. “We don’t rise up by repeating the past, we rise up from learning from the past.”

Virginia’s election is being closely watched by strategists in both parties. The off-year gubernatorial elections are often telling of which party will have the edge in the next midterms. The added dynamic of GOP race-baiting and some close recent polls have especially heightened Democrats’ nerves, as they worry if they can’t win a race in a state Clinton carried their hopes of a big 2018 may be unrealistic.

Obama delivered a dire warning — one that sounded much less like a stretch than in earlier years.

“Our democracy is at stake and it’s at stake right here in Virginia,” he said. “You are going to send a message all across this great country and all around the world of just what it is America stands for,” he said.

Northam has had a small but durable lead in most public polls of Virginia, where Trump’s deep unpopularity is dragging down former Gillespie in a state Trump lost. Gillespie has danced around Trump even as he’s gone hardline on immigration. Virginia Gov. Terry MacAuliffe joked that he was treating Trump like “a communicable disease.”

Obama slammed Gillespie for his Trumpian ads, which have gone after Northam for voting against a bill for sanctuary cities that was manufactured by Republicans even though no such cities exist in Virginia.

“What he’s really trying to deliver is fear. What he believes is if you scare enough voters you just might score enough votes to win an election,” he said of Gillespie’s attacks. “It’s just as cynical as politics gets.”

Obama said Northam would deliver on law and order “without fanning anti-immigrant sentiment,” and invoked the white supremacist violence in Charlottesville, an hour up the road, before ripping Gillespie’s “divisive” and “not true” attacks on Northam, a former army doctor.

“I don’t really think that somebody who spends his life operating on soldiers … is suddenly cozying up to street gangs,” he said.

While Obama didn’t mention Trump or Gillespie by name, Northam was happy to.

“My opponent, Ed Gillespie, is cut from the same cloth that Donald Trump is. He’s nothing more than a Washington lobbyist who’s become Donald Trump’s chief lobbyist,” he said after lamenting Trump’s campaign victory “based on hatred and bigotry and fear.”

It was clear that the crowd was there for the former president and not the Virginia Democratic ticket — the loudest applause of Northam’s whole speech was when he went to introduce Obama, having to pause after, “It is time.”

The biggest worry for Northam’s campaign is turning out base Democratic voters — especially the students and African Americans who appeared to make up a plurality of the crowd in Richmond. And it’s unclear how much Obama’s shine can wear off. The convention center had a solid crowd — the campaign said there were 6,250 people — but the room they’d booked was almost half-empty.

Obama specifically talked about the problem of turning out Democrats in off-year elections.

“Off-year elections, midterm elections, Democrats sometimes, y’all get a little sleepy, you get a little complacent,” he said. The stakes now don’t allow you to sleep. It’s going to come down to how bad you want it. I don’t want to hear folks complaining and not doing something about it. All the young people out here, you know, I think that it’s great that you hashtag and meme but I need you to vote.”

Obama’s speech was his second of the day, after stumping earlier for New Jersey gubernatorial front-runner Phil Murphy (D).