Thomas Smith, a retired General Motors engineer who had suspended his campaign weeks earlier, won the Republican primary for Michigan's 8th Congressional District on Tuesday, capturing just over 50 percent of the vote and defeating Amir Hassan, President Trump's endorsed candidate, by approximately 20 percentage points.

Smith announced he was suspending his campaign July 16, nearly three weeks before the primary. He also publicly endorsed another candidate in the race at the time, but his name remained on the ballot.

Voters chose him anyway—handing Trump a rare endorsement loss in a local race and leaving the Republican Party with a nominee who was not actively seeking the office.

Hassan had campaigned with Trump's backing in a district that covers a swath of southeastern Michigan. The president's endorsement typically commands significant pull with Republican primary voters, but it was not enough to overcome Smith's existing name recognition in the district.

Smith will now face the Democratic nominee in the November general election for a seat in the U.S. House of Representatives.