A Virginia judge on Tuesday ruled that longtime prosecutor Nicole Wittmann can run for commonwealth’s attorney in Loudoun County, dismissing a challenge by voters who argued she didn’t meet the residency requirement.

The ruling by Judge Richard Potter clears the way for Wittmann, a Republican, to appear on the ballot this fall. She will face Democrat Buta Biberaj, a defense attorney and substitute judge who is one of several candidates hoping to reform the criminal justice system in Northern Virginia. A group of Democratic voters had challenged Wittmann’s residency, noting that her family lived in Fairfax County through August.

“I’m very pleased; I’m not surprised,” Wittmann, now chief deputy in the prosecutor’s office, said after the trial in Loudoun circuit court. “I did everything right. I think it’s a testament to my devotion to Loudoun County — I uprooted my family.”

Wittmann testified at the day-long civil trial that she moved in with a colleague, Alejandra Rueda, the same week in February that she learned that Commonwealth’s Attorney Jim Plowman had been appointed a judge and would leave his job open. Wittmann also changed the address on her pay stubs to Leesburg in February and acquired a remote for her co-worker’s garage, she testified.

“I knew I needed to move into Loudoun County immediately,” she testified. “I moved to Leesburg as quickly as I could.”

On Feb. 21, Wittmann changed her car and voter registration to Rueda’s home and filed her candidacy papers. Potter cited those moves in his decision from the bench, along with the fact that Wittmann and her husband had considered moving to Loudoun in both 2013 and 2018.

“Her conduct clearly indicates her intent to move to Loudoun County from Fairfax County,” Potter said. “She took numerous steps.”

Potter is a Prince William judge brought in to hear the case to avoid a conflict of interest given Wittmann’s long career in Loudoun.

Wittmann testified that she had long wanted to move to a bigger home in Loudoun but had trouble selling her house in Herndon, a historic Victorian. She and her husband sold the house in July and, with their children, moved into a house in Sterling at the end of the month.

Rueda testified that she told Wittmann it would be “silly” to rent an apartment when she “had an extra bedroom that I didn’t use” in her Leesburg townhouse. Wittmann only paid her one rent check in March, for $205; Rueda said she was “very uncomfortable with being paid rent” because her colleague helped clean and take care of her two dogs.

Both women said Wittmann only stayed in the Leesburg house for about two week-long stretches between February and August. Otherwise, Rueda said, Wittmann’s presence was “erratic.” She got a key made for Wittmann in March, according to the court records.

Attorneys for Wittmann argued successfully that it was irrelevant how often Wittmann slept in Leesburg or whether she paid rent there — what mattered was her intention to live in Loudoun. Wittmann testified that she was in Leesburg as often as she could be and considered it her home — “with the exception of going back to care for my children.” She had primary responsibility for taking her kids to school and picking them up, she said, and was also often in Fairfax to care for two elderly relatives.

The plaintiffs were allowed to analyze Wittmann’s cellphone data, which showed dozens of examples of location data around the Herndon home and only two around Rueda’s Leesburg home. But Wittmann’s attorneys noted that she shared some phone applications with the rest of her family and that metadata can also be pulled in from downloaded images — for example, one image on her phone traced back to a location in the Bahamas.

Shown the longitude and latitude data on Google Maps, Wittmann testified that she did not recognize the location as her former home on Nash Street in Herndon, saying, “I’m familiar with multiple Nash and Spring streets.” The judge did not reference the cellphone records in his decision.

Michael York, a lawyer for the plaintiffs, declined to comment after the hearing other than to say he would examine a possible appeal. If that happens, no decision is likely to be made before the November election.