Lt. Gov. Ralph Northam responds to a moderator during a Democratic debate Tuesday in Norfolk with former congressman Tom Perriello. The two men, who will hold their last debate May 22, are campaigning ahead of a June 13 primary. (Stephen M. Katz/Associated Press)

The Democratic candidates for governor who are running neck and neck for their party’s nomination seemed to be battling different opponents during their fourth debate, as former congressman Tom Perriello repeatedly attacked President Trump and Republican front-runner Ed Gillespie instead of his primary opponent, Lt. Gov. Ralph Northam.

Northam, by contrast, kept his focus on state issues Tuesday night and invoked his Democratic allies in Virginia politics, from Gov. Terry McAuliffe to Sens. Mark R. Warner and Tim Kaine.

For two candidates who differ very little on issues, the approaches were telling. Perriello has enjoyed national attention lately as he has drawn endorsements from Sen. Bernie Sanders (I-Vt.) and Sen. Elizabeth Warren (D-Mass.), while launching a viral media campaign that taps into the enthusiasm of young progressives frustrated by Hillary Clinton’s defeat last fall.

[Shades of blue; two Dems vying for nomination differ mostly on style]

Northam, who has traveled the state for years building up support from Democratic elected officials at every level, has spent more on traditional TV ads and is running on his record of being able to navigate the demands of a Republican-controlled legislature.

Trump has been a theme in all their encounters, but Perriello went after the president and his recent scandals from the start of Tuesday’s debate, saying it was time to begin removing him from office.

“It’s incredibly important that we see leaders in Washington start to proceed with impeachment and special prosecutor proceedings,” Perriello said in his opening remarks. He referred to reports that Trump shared classified information with Russian diplomats as “reckless.”

He then called out Gillespie, the former chairman of the Republican National Committee who has a commanding lead in the GOP nomination race, saying that he “has been silent on these very serious charges.”

[Gillespie has big lead in GOP race, new poll finds]

Northam, by contrast, said a central difference between him and Perriello is that he has won statewide elections and has stood up to big business and special interests. “I have been pleased to work with Terry McAuliffe with the new Virginia economy,” he said, touting the state’s 3.8 percent unemployment rate.

The debate was co-sponsored by the Greater Hampton Roads Black Democrats. The African American vote will be an important factor in winning what is usually a low-turnout primary, and both candidates have spent time cultivating African American community leaders.

Issues of race came up a couple of times Tuesday evening, as both candidates condemned recent demonstrations in Charlottesville by white supremacist groups seeking to preserve Confederate statues.

One questioner asked why the opioid crisis raging in many white, rural communities is being treated as a mental health issue when the crack epidemic that ravaged African American communities was treated as a crime.

Perriello took the topic as a chance to condemn Attorney General Jeff Sessions for his “racist dog-whistling politics,” and both he and Northam called for decriminalizing marijuana and reforming the criminal justice system so that African Americans are not disproportionately targeted.

The two candidates stuck to their story lines for most of the debate, and refrained from some of the needling of one another that has marked their recent encounters. Speaking to a well-behaved crowd of about 100 in the studios of WHRO public television, the two touched on issues that are big in Hampton Roads, such as sea level rise and dependence on government contracting.

Northam, who represented Norfolk in the state Senate and is from a fishing village on the Eastern Shore, took pains to talk about his efforts to get federal funding to study resiliency as a way to help the region withstand and adjust to rising sea levels.

Perriello talked more broadly about the need to pursue alternative energy sources that will help address climate change.

[Perriello and Stewart each try to ride a wave of populism into governor’s mansion ]

But time after time, Northam tackled questions by saying what he would do with the state legislature, while Perriello threw the issues back at the president and their Republican opponent.

On health care, Perriello touted his support in Congress for the Affordable Care Act and then blamed Republicans and Trump for working to repeal it — and attacked Gillespie for saying he would consider a state waiver that would allow insurers to charge different rates for people with preexisting conditions.

“Unfortunately, Ed Gillespie has said that he would put his insurance company clients ahead of the citizens of Virginia,” he said.

Once again, the issue of gas pipelines in Virginia served to highlight their narrow policy differences. As he has in every debate, Northam declined to take a hard yes-or-no stance on the two pipelines proposed for Western and Southern Virginia, saying only that they need to be subject to careful environmental review.

[Virginia power broker in the hot seat]

Perriello sharply opposes the pipelines, and took the opportunity to throw it back at Northam in terms the Hampton Roads audience would relate to — suggesting that continued reliance on fossil fuels would contribute to sea level rise. Allowing the pipelines is “like someone coming to you right when digital cameras were taking off and saying you should bet your pension fund on Eastman Kodak,” he said, drawing the only audience laughter of the night.

Northam jabbed Perriello for getting support from the National Rifle Association when he was in Congress and for supporting an Affordable Care Act amendment that would have restricted federal funding for abortions. A pediatric neurologist, Northam has won endorsements from NARAL and has worked closely with other women’s health advocates.

But Perriello kept turning his remarks back to Gillespie and Republicans in Washington. While Northam, 57, concluded with a moving — but familiar — refrain about the hope he sees in the eyes of his young patients, Perriello, 42, suggested that Virginians are ready for something new.

“We can’t afford to continue to change things around the margin. We need a new generation of ideas,” he said.

The two men, who will hold their last debate May 22, are campaigning ahead of a June 13 primary. On the same day, Republicans will choose from among three candidates — Gillespie; state Sen. Frank W. Wagner (Virginia Beach) and Prince William County Supervisor Corey A. Stewart.