AUSTIN, Texas — Democrats sued Wednesday to keep Texas Republican Rep. Blake Farenthold’s name on the 2018 ballot even though the congressman says he won’t seek a fifth term amid allegations of sexual harassment.

The lawsuit filed in an Austin federal court came hours after GOP officials said they would remove Farenthold’s name despite him missing the deadline for candidates to withdraw.

Farenthold announced last week he wouldn’t seek re-election amid pressure from fellow Republicans. He did so while denying 3-year-old accusations that he’d subjected a former aide to sexually suggestive comments, but also apologized for an office atmosphere he said included “destructive gossip, offhand comments” and other behavior.

His decision came four days past the deadline in Texas for candidates to withdraw, prompting the Texas GOP to file a lawsuit in hopes of still removing his name. The party claimed victory Wednesday, saying state elections officials had signaled they couldn’t force Farenthold’s name to remain on the ballot.

Democrats accused Republicans of skirting the rules and asked a federal judge for an injunction.

“Farenthold has no business serving in public office, but the primary ballot is set and he failed to withdraw,” Texas Democratic Party Chairman Gilbert Hinojosa said in a statement.

In 2006, Democrats sued to keep former U.S. House Majority Tom DeLay on the ballot when the powerful Republican resigned after being indicted. Republicans weren’t allowed to replace DeLay, who had already won his primary, and instead had to back a write-in GOP candidate who went on to lose to Democrat Nick Lampson.

Six Republicans and four Democrats are vying to replace Farenthold.

READ MORE: Al Franken, Trent Franks join long list of lawmakers ousted by scandal