Former Stafford County supervisor Paul Milde, who is challenging Del. Robert M. Thomas Jr. in Tuesday’s Republican primary, has a criminal record that hasn’t stopped voters from electing him three times in the past.

But it has emerged as an issue in the hotly contested race between Milde and Thomas in the 28th District, which includes parts of Fredericksburg and Stafford County.

In 1986, when he was 18, Milde was convicted of possession of cocaine with the intent to distribute — a felony — in Prince William County. He was sentenced to six years in prison, with five years suspended.

Nine years later, Milde pleaded guilty to being an accessory after the fact to an attempted burglary in Fairfax County — a misdemeanor for which he was sentenced to 360 days, all but 20 suspended.

He has said that he learned about the burglary after the fact because someone he was mentoring in Narcotics Anonymous had confessed to him. He said he did not want to violate the man’s trust, so he refused to tell police, resulting in the charge.

But his explanation is at odds with sworn testimony given in his case in 1995, which suggests that he took part in the burglary — an attempt to break into a Foot Locker near the Loudoun County line in the Sterling area.

In a 1994 hearing in Fairfax County District Court, Milde’s fiancee, Amy Elizabeth Glover, testified under oath that Milde told her that he and the couple’s roommate, Brian Wade, had tried to cut a hole in the roof of a Foot Locker they intended to burglarize.

Glover testified that Milde called her the night of the burglary, asking her in hushed tones to pick him up in Occoquan and bring him a change of clothes.

She arrived to find him muddy and scratched up — the result of running away from the Foot Locker store through the woods before taking a cab to Occoquan, she testified.

Glover testified that Milde told her he and Wade scaled the store building with a ladder and tried to gain entry by cutting a hole in the roof, tripping an alarm.

During the hearing, Milde’s attorney said Glover made up the part about Milde’s confession in a bid to gain sole custody of couple’s toddler son.

Milde, now 51, initially was charged with attempted burglary, possession of burglary tools and possession of a weapon by a convicted felon. He eventually pleaded guilty to the lesser charge of accessory to burglary after the fact. The other charges were dropped as part of the plea deal.

In an interview this week, Stephen A. Best, the prosecutor who handled the case, called Milde’s explanation that he was not involved in the actual burglary “utter nonsense and a complete lie.”

Milde campaign manager Dustin Curtis stood by the candidate’s account and said political foes were seeking to undermine Milde on the eve of the primary — a bitter rematch with Thomas, who beat Milde for the nomination in 2017.

“Paul Milde has been clear all along and owned up to facts,” Curtis said. “People with a political agenda are attempting to rewrite history.”

A spokesman for Thomas, 42, who is running for a second term, declined to comment on the court records. Thomas served on the Stafford Board of Supervisors before his election to the General Assembly.

But the Thomas campaign has attacked Milde over his criminal convictions. One mailer makes note of the cocaine and burglary charges, as well as traffic violations, with the words, “Convicted felon Paul Milde” at the top. “We can’t have a trainwreck represent us in Richmond,” it says.

Milde has responded with a flier with a photo of a skeleton looming behind a rack of dress shirts. “Bob Thomas says I have skeletons in my closet,” it begins. In it, he explains his cocaine conviction, though not the burglary. He suggests voters should care more about recent behavior, including Thomas’s decision in early 2018 to vote with Democrats to expand Medicaid under the Affordable Care Act. Thomas had run for office on a pledge to oppose expansion.

“What I did 33 years ago was wrong. I deserved to be punished and I was,” Milde says in the flier. “I admit to the truth. The problem is Bob Thomas won’t admit that since he got to Richmond last year, he’s been voting with the Democrats to advance their liberal agenda.”

The Republican who wins Tuesday will face Democrat Joshua Cole in November.

Jenna Portnoy and Julie Tate contributed to this report.