Incumbent Mark Herring won the Democratic nomination Tuesday to seek a third term as Virginia’s attorney general after campaigning on a liberal record that included battling President Donald Trump, defending same-sex marriage and supporting gun restrictions.

Herring held off a challenge from Del. Jerrauld C. “Jay” Jones (Norfolk), a newcomer to statewide politics who was hoping to become the first Black man to be Virginia’s top attorney.

The victory gives Herring an opportunity to make a bit of history of his own in November. If he wins the general election, he could rank among the longest-serving attorneys general in the history of the state.

Jones, 32, hoped voters were hungry for new leadership, casting himself as a fresh voice for a more diverse and progressive Democratic coalition and someone who would act with greater urgency to address police violence against minority communities. Gov. Ralph Northam (D) endorsed him.

But Virginia’s Democratic voters, who historically have been risk averse, sided with Herring, 59, who is one of the most experienced and well-known Democratic politicians in the state.

“Jones ran an effective campaign against extremely difficult odds. It’s always tough to beat an incumbent,” said University of Mary Washington political science professor Stephen Farnsworth. “Herring has spent years building up the kind of record needed to win a Democratic primary, and that’s one of the key reasons that he prevailed.”

Herring initially did not plan to run for another term for attorney general.

He announced a candidacy for governor in 2018, but dropped the bid last year before Democratic heavyweight and former governor Terry McAuliffe announced he was interested in running for the state’s top office. McAuliffe won Tuesday’s gubernatorial primary.

Herring also was challenged by a scandal in 2019, where it was revealed shortly after he attacked Northam for his blackface scandal that Herring had darkened his face to look like a rapper during a college party in 1980. Herring apologized for the incident.

During the primary, Herring pitched himself as the “people’s lawyer,” touting how he won the nation’s first injunction on the Trump administration’s ban on travelers from a handful of Muslim-majority nations, defended the Affordable Care Act and expanded in-state college tuition to young people who were brought to this country illegally as children.

That record seemed to resonate with some voters.

In Norfolk, Douglas Greene, 76, a retired Old Dominion University history professor, said Herring’s positions on same-sex marriage, Planned Parenthood and other issues showed him to be a progressive worthy of another term.

He said he liked Jones, but Jones needed more time before he was ready. “It’s too early for him,” Greene said.

Herring said he still has more to accomplish after two terms, and will focus on police reform and racial justice, health issues and worker’s rights and safety in a potential third term.

“Our message was pretty simple: After eight years of incredible progress, we showed that experience and know how really pays off,” Herring said in an interview.

Jones often spoke of his family’s journey from enslavement to breaking barriers in Virginia to frame how his own run for attorney general could be another first.

He said his lived experience as a Black man made him particularly prepared, as the nation grapples with a reckoning over race and policing.

Jones pointedly criticized Herring’s handling of high-profile encounters between police officers and people of color that grabbed headlines during the campaign, saying Herring was too reactive.

He also jabbed at Herring over the more than $800,000 spent on his behalf by the Democratic Attorneys General Association.

“Tonight’s result is disappointing, but we will not let it deter us from continuing the fight to bring true reform to Virginia,” Jones said in a statement. “We must elect leaders who will be proactive, not reactive and rise to meet this moment in our history.”

Even though Jones didn’t come out on top, Farnsworth said his run could pay political dividends in the long run.

“Jones’s campaign might put him a better place for a future statewide race,” Farnsworth said. “Losing isn’t necessarily a bad thing if no one expects you to win in the first place. You build name recognition. You learn how to run statewide.”

In the general election, Herring will take on Republican Del. Jason Miyares, a former prosecutor from Virginia Beach and son of a Cuban immigrant.

Miyares beat out three other candidates to take the GOP nomination in May.

Farnsworth said a bruising political contest is possible, since the attorney general’s race typically draws ideological candidates on both sides of the political aisle.

Herring wasted no time in attacking Miyares, saying he would have “no difficulty drawing a stark contrast” with his opponent’s positions on health care, guns and criminal justice reform.

In a statement, Miyares said the policies Herring and the Democratic-controlled legislature support on parole, bail reform and mandatory minimums are making Virginians less safe.

“Attorney General Herring has decided to side with criminals over law-abiding citizens,” Miyares said in the statement. “Attorney General Herring and the Democrat led legislature supported laws that will bring more violent criminals into our neighborhoods.”

State records show that if Herring wins in November and serves a four-year term, he will be among a handful of attorneys general who have served more than a decade.

Often, the job has been seen as a steppingstone to the governor’s mansion. Many attorneys general have resigned to seek higher office.

Democrats have already tipped their hand on a general election strategy: tie Miyares to Trump.

An ad by a new political action committee launched on social media in recent days features an image of Trump — who remains deeply unpopular in Virginia — looming over the shoulder of Miyares.

The ad’s tagline says the state needs an attorney general for Virginia, “not for Donald Trump.”

Jim Morrison contributed to this report.