Republican Del. Jason S. Miyares has upset a two-term Democratic incumbent to become Virginia’s next attorney general, making him the first Latino elected to the office in the history of the state.

Miyares, a former prosecutor who was little known outside of his Virginia Beach district before this run, paired a hard-edge, tough-on-crime message with a softer, more uplifting appeal centered on his family’s story of emigrating from Cuba.

Miyares was buoyed by a conservative wave that helped sweep Republicans Glenn Youngkin into the governor’s mansion and, according to the Edison Research Group, Winsome E. Sears into the lieutenant governor’s office.

Miyares narrowly defeated Democrat Mark R. Herring, a marquee political name who conceded Wednesday evening and had touted his efforts to turn the attorney general’s office into a liberal bastion during the campaign.

Miyares has promised an about-face, saying he would take a stricter line on criminal offenders, support police, push for what he calls “common sense” measures to prevent voting fraud and probe the constitutionality of some laws passed by a legislature controlled by Democrats.

In an interview, Miyares said he also would be the first child of an immigrant to hold the attorney general’s office, and that he would be proud to represent “new Virginians.”

“It’s so humbling for me that almost 56 years after my mother left [Cuba] penniless and homeless, I’m going to be the top lawyer in the state,” Miyares said. “That’s something I’ll think about every day in office.”

In a message to his supporters, Miyares wrote he vowed “to fight for law and order and keep our community safe” as attorney general, building on the theme that was central to his campaign.

In a Wednesday statement, Herring said he called Miyares to congratulate him on the win. “From the bottom of my heart, I thank the people of Virginia for trusting me to serve as your attorney general for the last eight years,” Herring said.

Herring can point to a substantial record of achievements over two terms. He famously declined to defend Virginia’s ban on same-sex marriage early in his first term, won the nation’s first injunction against President Donald Trump’s ban on travelers from majority-Muslim nations, found that immigrant “dreamers” brought here as children were eligible for in-state tuition and lifted regulations by his predecessor that would have shuttered most abortion clinics in the state.

But after nearly eight years of using the attorney general’s office as a “progressive powerhouse,” as Herring liked to term it, Miyares said he plans to take it in a very different direction.

Miyares said in an interview that his top priority in office would be investigating the state’s parole board over its controversial handling of the release of a handful of violent felons. He said the board’s actions had failed victims of crime.

Miyares also pointed out two liberal Northern Virginia prosecutors by name — Fairfax County’s Steve Descano and Loudoun County’s Buta Biberaj — for what he called their lax handling of child sex abuse cases and domestic violence. Miyares said he would push for a bill in the state legislature that would allow the attorney general’s office to prosecute child sex offenses when county prosecutors decline to act.

Miyares cited a case in Fairfax County where the family of a girl who suffered years of sexual abuse objected to the sentence Descano’s office agreed to as part of a plea deal with the defendant, saying it was not long enough.

“If they are not going to do their job, I’m going to do their job for them,” Miyares said.

Descano accused Miyares of playing politics.

“Mr. Miyares is using victims to score cheap political points — cases of child sex abuse and domestic abuse are a top priority for this office, which is why I created specialized units to prosecute them,” Descano said in a statement. “Mr. Miyares is simply intent on overriding the will of the people of Fairfax and reimposing a retrograde and ineffective justice system that Fairfax residents have rejected time and again — including on Tuesday night.”

Biberaj said in a statement she expected better of a former prosecutor.

“Loudoun residents care about safety and justice, but also process and facts. Despite recent efforts propagated by some candidates running, including the AG-elect, to suggest otherwise, our office will continue to fight for fairness, safety and equity,” Biberaj said.

Miyares, 45, was successful in his first run for statewide office, knocking off an incumbent who had created a national reputation taking on Trump and pushing for liberal causes on a range of hot-button issues from gun control to abortion.

During the campaign, Miyares highlighted his experience as a prosecutor in Virginia Beach in making his pitch to voters that he was better equipped to deal with a surging murder rate in Virginia that hit a two-decade high over the summer.

Miyares said he thought Republicans were triumphant in Virginia on Tuesday because they focused on basic issues that intersected with voters’ everyday lives.

“I think the big lesson we took from the election is we talked about Virginia issues affecting Virginians — the murder rate is up, prices are up,” Miyares said. “Quite clearly you saw a revolt in the suburbs about what was happening in the schools.”