President Barack Obama will hit the campaign trail on Thursday for the first time since leaving office, trying to rally black voters behind candidates for governor in Virginia and New Jersey amid warnings that they may not come out in force on an Election Day that is just three weeks away.

Obama’s appearances on behalf of Virginia’s lieutenant governor, Ralph Northam, in Richmond and financier Philip Murphy in Newark — two white candidates in predominantly black cities — come as Democrats struggle to inspire African-Americans to vote this year. While Murphy appears comfortably in the lead in New Jersey, the race in Virginia is close.

And in Alabama, where voters go to the polls on 12 December, Doug Jones, a former prosecutor, is running a surprisingly competitive race for the Senate against the firebrand social conservative Roy Moore.

Barack Obama and Donald Trump reacted to mass shootings quite differently

“There is not one person in Birmingham who disagrees we need Doug Jones,” said Randall Woodfin, the newly elected mayor of Alabama’s largest city, which is predominantly black. “The issue is motivating them to come out and vote for him.”

The party’s dilemma echoes a challenge that Democrats have faced in elections since Obama’s rise to the presidency: how to persuade some of the most loyal voters to show up for elections when the Democrat they most love is not a candidate. In 2017, antipathy for President Donald Trump could be a new motivation, but Trump is not on the ballot either.

Phillip Thompson, the President of the NAACP in Virginia’s Loudoun County, said he was worried that black voters were simply not engaged.

“I’m just not getting the vibe on it,” he said. “Not at all.”

Obama may be a draw, but there are limits to what he can accomplish as a surrogate campaigner during brief forays into electoral politics. Democrats recall too well the dip in black turnout in the decisive states of Michigan, Pennsylvania and Wisconsin that doomed Hillary Clinton last year. That same dip was partly to blame for the down-ballot losses that Democrats suffered earlier in Obama’s term.

Another slump in 2018 would imperil the party’s efforts to capture the House, hold its own in the Senate and win key governorships.

“If the party doesn’t change what they’re doing, we’re not going to take back the House, we’ll lose seats in the Senate and folks will come around after and say, ‘What happened?'” warned Representative Cedric Richmond (Democrat-Louisiana), chairman of the Congressional Black Caucus. “We are doing a pathetic job of reaching out to minority voters.”

In both Alabama and Virginia, Democrats have tried to lay the groundwork for stronger black turnout in 2017 and midterms next year. Officials with the Democratic Congressional Campaign Committee briefed party strategists this month on plans to conduct research in several states, including New Jersey and Virginia, to identify issues most likely to motivate minority voting in 2018.

Michelle Obama calls out Trump without mentioning his name

In Alabama, national leaders, including Senators Chuck Schumer (Democrat-New York) and Bernie Sanders (Independent-Vermont) have appealed to Woodfin to deploy his field organization to help Jones in the special election for the Senate.

Woodfin, a 36-year-old insurgent who toppled an incumbent Democrat this month, said he intended to help Jones, who convicted two Ku Klux Klansmen for a Civil Rights-era church bombing in his city. African-Americans are “looking for people to fight for their issues,” he said.

In Virginia, Northam has targeted black voters in the final weeks of the race, frequenting black churches and campaigning with Eric Holder Jr, the former attorney general, in addition to Obama.

But Northam’s overtures have been met with mixed results.

Kathy Harkless and two of her fellow congregants at First Mount Zion Baptist Church had just met Northam after he attended worship services here Sunday, but when asked about his bid for governor, they quickly steered the conversation toward Washington.

“I don’t want what we have now,” said Harkless, referring to Trump. “It’s awful.”

It is a familiar refrain to Dr Luke Torian, who divides his time pastoring the church, founded 150 years ago by former slaves, and representing parts of this Washington exurb in the state legislature.

“The lieutenant governor’s campaign has to make some of the current administration’s issues resonate,” he said. “That’s going to be his challenge.”

Northam seems well prepared to engage black residents. He attended integrated schools as a child on Virginia’s eastern shore and often worships at a black church when back home. He won African-American voters decisively in the Democratic primary this year, and has put opposition to Trump at the center of his message.

But Northam has also been uncertain about how to handle calls to remove Confederate statues in the state after the bloodshed in Charlottesville this summer, seemingly torn between not wanting to offend whites in this history-drenched state and not wanting to get crosswise with his African-American base. After initially saying he would be “a vocal advocate” for taking down the monuments, Northam, facing an onslaught of ads from his Republican opponent over the issue, said last week that he was “not going to meddle” with localities over the issue.

Elected Democrats in Virginia suggest the anger toward Trump will ultimately translate into votes. “The national circus is overshadowing it, but if you’re on the doors like I am, you’re hearing that excitement and you’re hearing the people excited to vote,” said Marcia Price, a delegate.

The Alabama contest is even more delicate for Democrats, because of the state’s intensely polarised racial politics. But Democrats believe Jones has a slim path to victory.

To win, Jones must maximize turnout among the quarter of voters who are black, while capturing about a third of the overwhelmingly white Republican population. Democrats have little infrastructure left in the state. Old-guard black groups have withered, and Republicans have won every statewide office for a decade.

Barack Obama's best moments in the White House Show all 11 1 /11 Barack Obama's best moments in the White House Barack Obama's best moments in the White House May 19, 2009 “The President was leaving the State Floor after an event and found Sasha in the elevator ready to head upstairs to the private residence. He decided to ride upstairs with her before returning to the Oval Office,” Peter Souza Barack Obama's best moments in the White House Oct. 26, 2012 President Barack Obama pretends to be caught in Spider-Man's web as he greets the son of a White House staffer in the Outer Oval Office Peter Souza Barack Obama's best moments in the White House “A National Security staffer, Carlton Philadelphia, brought his family to the Oval Office for a farewell photo with President Obama. Carlton’s son, Jacob, softly told the President he had just gotten a haircut like President Obama, and asked if he could feel the President’s head to see if it felt the same as his.” Peter Souza Barack Obama's best moments in the White House March 21, 2010 The President, Vice President and senior staff applaud after watching on television the House vote on H.R. 4872 for health care reform, in the Roosevelt Room of the White House Peter Souza Barack Obama's best moments in the White House Dec. 3, 2009 President Barack Obama fist-bumps custodian Lawrence Lipscomb in the Eisenhower Executive Office Building following the opening session of the White House Forum on Jobs and Economic Growth Peter Souza Barack Obama's best moments in the White House Sept. 22, 2015 "The Obama family and Biden family greet Pope Francis as he arrives in the United States for the first time at Joint Base Andrews," Sept. 22, 2015. Peter Souza Barack Obama's best moments in the White House Feb. 21, 2014 President Barack Obama and Vice President Joe Biden participate in a "Let's Move!" video taping on the Colonnade of the White House, Feb. 21, 2014 Peter Souza Barack Obama's best moments in the White House Feb. 18, 2016 President Barack Obama watches First Lady Michelle Obama dance with 106-Year-Old Virginia McLaurin in the Blue Room of the White House prior to a reception celebrating African American History Month, Feb. 18, 2016 Peter Souza Barack Obama's best moments in the White House Jan. 21, 2013 "The President and First Lady wave to supporters as they ride in the inaugural parade. I had asked the President if I could ride in the presidential limousine and the President joked, 'But Michelle and I were planning to make out," Jan. 21, 2013. Peter Souza Barack Obama's best moments in the White House Barack Obama and former First Lady Michelle Obama share a private moment in a freight elevator at an Inaugural Ball, January 2009 all pics: Pete Souza Barack Obama's best moments in the White House Barack Obama rests his hand on the bible that President Lincoln used for his swear-in, being held by his wife Michelle Obama as he is sworn in as the 44th President of the United States of America Rex

Jones has put his legal pursuit of the Klan at the centre of his message and has reached out to leaders of the Congressional Black Caucus, including Richmond. Representative Hakeem Jeffries (Democrat-New York), a member of the House leadership team, said he met with Jones and was watching the race closely.

To turn out black voters in 2018, Jeffries said, Democrats would have to go beyond “doing drive-bys in African-American churches.”

“Those days need to be over if Democrats are serious about winning,” Jeffries said.