Representative Dan Donovan, a New York Republican, successfully fended off a fierce challenge from his predecessor, Michael Grimm, avoiding the ignominious fate of losing re-election to a convicted tax cheat, according to The Associated Press.

Mr. Grimm had resigned his Staten Island seat in 2014 and pleaded guilty to felony tax evasion, serving seven months in prison. But not long after he was paroled, Mr. Grimm began plotting his comeback bid to unseat Mr. Donovan, the former Staten Island district attorney who had replaced him in Washington.

Mr. Donovan, 61, had the full weight of the Republican Party behind him. President Trump endorsed him; Donald Trump Jr. recorded a get-out-the-vote phone call; former Mayor Rudolph W. Giuliani held a rally; outside groups, including the United States Chamber of Commerce and a Trump affiliated super PAC, spent more than $1 million on Mr. Donovan’s behalf.

The victory denies Democrats the chance to run against a felon in November in the lone Republican-held congressional district left in New York City — a seat that has proved elusive for the party in the past. Max Rose, an Army veteran, won the Democratic nomination on Tuesday, and had more than $1 million banked as of the latest filing period.