CULPEPER, Va. — Republican Del. Nicholas J. Freitas, a charismatic former Green Beret with a libertarian streak, should have been a shoo-in for reelection in a rural Virginia district east of Shenandoah National Park that heavily favored President Trump.

But as he seeks a third term on Nov. 5, his name will not be on the ballot. Only one candidate will be listed for Virginia’s 30th House district — Ann Ridgeway, the Democrat trying to unseat him. Freitas and his local party failed to file two forms with the state elections office on time, so he’s been forced to run as a write-in candidate.

The misstep has been a setback for Republicans in a year when they cannot afford to lose a single seat. Control of the General Assembly is up for grabs, with all 140 seats on the ballot and the GOP defending a 51-to-48 majority in the House and a 20-to-19 edge in the Senate, with one vacancy in each chamber.

A write-in candidate has not won in Virginia for a generation. The last time was in 1989, when independent Jackie Stump, president of the local coal miners’ union in far southwest Virginia, pulled one off in the midst of a bitter strike to win a House of Delegates seat.

“I feel bad for the guy, but he didn’t care enough to make sure the forms were filled out,” said Ridgeway, 67, a former teacher and juvenile probation officer.

Freitas’s flub is not considered likely to cost him reelection given the bright red nature of the district, which covers Madison and Orange counties, and part of Culpeper. But it is forcing Freitas, 40, to spend more time and money on the campaign than planned. The episode could also cost him political capital with his own party at a time when he is widely thought to have his eye on higher office, including a possible challenge to Rep. Abigail Spanberger (D-Va.) next year.

Freitas spoke at a recent anti-impeachment rally outside Spanberger’s Henrico County office but said that was to support Trump, not to signal his interest in a congressional bid.

“I am entirely focused on my House of Delegates race,” said Freitas, a defense consultant who served in the Army in Iraq on two combat tours.

He promised to raise all of the money he needs for the write-in bid without help from the House Republican Caucus, so he would not be a drain on GOP resources. Richard Uihlein, a GOP megadonor from Illinois, has bankrolled the bulk of his campaign with a $500,000 donation, some of which Freitas has shared with other legislative candidates.

Uihlein, who typically shuns the spotlight, did not respond to messages seeking comment. The shipping supplies mogul, a prolific donor during the 2018 midterms, tends to support candidates who share his opposition to unions and affinity for free markets and small government.

Freitas has vastly outraised Ridgeway, having pulled in $688,000 since January. He had $170,000 on hand heading into October. She has raised $80,000 and had $38,000 in cash.

“Nick is only alive because of Rich Uihlein’s money,” Jake Rubenstein, spokesman for the Democratic Party of Virginia, said in an email. “You might as well write in U-I-H-L-E-I-N if you want to vote for Nick.”

Much of the GOP establishment rallied around Freitas last year as he battled Republican Corey A. Stewart for their party’s U.S. Senate nomination. With Stewart embracing Confederate heritage and engaging in Trump­ian antics, some Republicans saw Freitas as a fresh face who could help re-brand a party that had not won a statewide election for a decade.

Freitas narrowly lost the nomination to Stewart, who went on to get clobbered in the general election by Sen. Tim Kaine (D).

With no primary challenger for his House seat, the delegate began 2019 seemingly poised to play an outsize role in legislative elections. Breaking with protocol, he waded into a bitter nomination battle between a Republican colleague, Del. Christopher K. Peace (Hanover), and the challenger who ultimately beat him, Scott Wyatt. Freitas’s wife, Tina Freitas, mounted a GOP primary challenge against Sen. Emmett W. Hanger Jr. (Augusta). She was soundly defeated.

Amid all that, state elections officials said Freitas’s local Republican legislative committee never submitted a required form indicating he was the party’s nominee. The state said a second form, which Freitas personally should have filed, also was missing.

Bruce Kay, chairman of the GOP’s 30th legislative district, said at the time that he had emailed the nomination form to an outdated address. He said he could not provide a copy of his email as proof because of a computer glitch.

Committees for two other delegate candidates — one Republican, one Democrat — said they had similar problems but at least one produced a copy of an errant email, and both of those candidates had submitted the second form. The elections board agreed to list those two on the ballot but said Freitas’s case was different because both forms were missing.

“Maybe he should have spent less time trying to create a family political business or meddling in his colleagues races,” Peace tweeted in the summer while Freitas’s ballot troubles began unfolding.

As Freitas considered how to get his name on the ballot, rifts with party leaders opened in public. A former Freitas aide tangled on Facebook with House Majority Leader Todd Gilbert (R-Shenandoah), accusing GOP leaders of not supporting Freitas.

“Oh YOU must be the mastermind behind the scenes who would rather run a write-in campaign than try to get a Republican on the ballot in an otherwise safe district when control of the state government is at stake,” Gilbert shot back. “Shame on me?”

But party leaders soon lined up behind Freitas.

“Nick recognizes what he has to do to be successful on November 5th and has put together a top-notch team to help us hold the majority,” Gilbert said in a written statement this week. “The 30th House district knows Nick, and he’s a great fit for it. There’s no doubt in my mind that he’s headed back to Richmond in January.”

Freitas is running for reelection in a rural district where Trump beat Hillary Clinton 61 percent to 34 percent — despite losing the state overall by six points. Two years ago, as Democrats picked up 15 House seats in an anti-Trump wave, Freitas beat Democratic challenger Ben Hixon 62 percent to 38 percent, despite being outspent nearly 2 to 1.

But a write-in campaign presents special challenges. Freitas has sought advice from part of the team that helped Sen. Lisa Murkowski (R-Alaska) win a write-in bid in 2010.

His billboards, mailers and volunteers focus on the nitty-gritty of casting a write-in ballot. Voters must write his name — spelling need not be perfect — and fill in a bubble beside the words “write-in.” The vote won’t count if the bubble isn’t filled in, unless there’s a recount.

Freitas said he’s undaunted: “We’re going to fight all the way until the polls close.”

In mailings, he blames his predicament on politics — something even the lone Republican on the three-member state elections board has disputed.

“Democrat-appointed bureaucrats in Richmond kept Republican nominee Nick Freitas off the ballot in order to help Democrats flip the House and take total control of Virginia government,” one reads. “They’ve limited your choice on the ballot in an effort to elect the radical Democrat nominee.”

Ridgeway, who lives on a farm in Madison, said she is surprised to see herself described as a “radical.” A political newcomer and daughter of an Episcopal minister, she wants to expand mental health services and rural broadband, and improve schools. She says both parties need to compromise on certain flash points, such as guns and abortion.

“I think reds and blues have to work together,” she said.

On guns, she wants criminal background checks for all purchases and a “red flag” law that would allow authorities to temporarily seize firearms from people deemed a danger to themselves or others.

“I’m not interested in confiscation,” she said. “I live in the country. We have rabid animals. Guns are something that you have.”

On abortion, she thinks the procedure should be legal in the first trimester but an option later in pregnancy only for medical reasons, such as if the mother’s life is in danger or the fetus is not viable.

“I had seven miscarriages. I’ve had a lot of loss in my life,” said Ridgeway, who has two grown daughters but lost a son at age 6 in a car accident. “I respect the concept of life and I know how precious life is. And I know how quickly it can end.”

Freitas, who has three young children, sometimes invokes the sacrifices made by his mother when discussing his opposition to abortion. She got pregnant in college and dropped out to have him.

“I have no idea what it is like to be a young woman that finds herself in a situation that she did not anticipate, that is now going to drastically alter her life,” he said during a September speech in Austin. “I have no idea what it’s like to be that woman. I do know what it’s like to be her son.”

More often, he strikes a harder tone, railing against the “abortion industry” or saying Democrats cannot be trusted not to turn “red-flag” laws into a “massive power grab.”

“When was the last time Democrats infringed on essential liberties for political purposes?” he asked, sarcastically, in the Texas speech. “I mean other than, like, slavery, fighting against women’s suffrage, Japanese internment camps, segregation, massive resistance, Jim Crow laws — other than those?

The speech was one of five unpaid appearances he has made since April at gatherings around the country of Young Americans for Liberty, the libertarian equivalent to College Republicans and an offshoot of the 2008 presidential campaign by then-Rep. Ron Paul (R-Tex.).

Freitas came to the attention of Young Americans for Liberty last year during his U.S. Senate bid.

Now Freitas is a regular keynote speaker at YAL conventions, usually paired with Paul; Paul’s son, Sen. Rand Paul (R-Ky.); or a key ally of the Pauls, Rep. Thomas Massie (R-Ky.).

Cliff Maloney Jr., the group’s president, said Freitas’s “electric keynote address” has been a staple of its gatherings. “From his experience on the battlefield to his rigorous defense of personal liberty . . . he is dynamite,” Maloney said.

Freitas went to Philadelphia for one convention in the spring, during his wife’s primary battle. The others took him to Memphis, San Jose, Austin and Detroit in the summer and fall, after his fate as a write-in candidate had been sealed.

Some Republicans have grumbled about Freitas’s time off the trail. Freitas agreed to the appearances before he knew he would have to run as a write-in, campaign manager Joe Desilets said.

Bounding onto the stage in Austin in jeans, a blazer and cowboy boots, Freitas gave a lesson on how to shut down arguments for gun control with blunt one-liners.

To the Democrat who suggests, “If you need 30 rounds to hunt, you suck at hunting,” Freitas had a comeback: “Well if you need an unarmed populace to govern, you suck at governing.”

To those who’d claim “nobody needs an AR-15,” he had a retort invoking the Democratic presidential contender and former congressman from Texas who is calling for a mandatory buyback for assault weapons.

“Well nobody needs an ignorant, whiny little punk, but Beto O’Rourke’s allowed to walk free,” Freitas said, drawing cheers. “Next time he’s in Virginia, if he wants to come confiscate some guns, he can walk his skinny ass over to my house and give it a shot.”