House Speaker Paul Ryan has defeated a longshot Republican primary challenger who had been praised by Donald Trump.

Ryan beat businessman Paul Nehlen in Tuesday's Wisconsin primary. Nehlen had been courting Trump supporters and won praise from the Republican presidential nominee last week. But Trump endorsed Ryan days later.

Ryan had largely ignored Nehlen in what had been a sleepy primary before Trump thanked Nehlen on Twitter for his comments defending Trump. Nehlen won the backing of some prominent conservative figures, including former Alaska Gov. Sarah Palin, but it wasn't enough to overcome Ryan's popularity in his southeastern Wisconsin district.

Ryan was first elected in 1998 and this is his first re-election win since becoming speaker last fall.

Trump Booed Leaving New York Times

President Elect Donald Trump is booed as he walks through the lobby of The New York Times Building after a 75-minute meeting with Times journalists. The lobby of the Times building is open to the public, and a large crowd had gathered by the time he departed. (Published Tuesday, Nov. 22, 2016)

He went into the primary with massive advantages in name recognition and money. Ryan had outraised the unknown Nehlen by a 17 to 1 ratio through the latest reporting period, and was largely ignoring his opponent and was expected to win easily.

Trump changed all that the week before the primary, when he tweeted thanks to Nehlen for support while Trump was being vilified for remarks about the Muslim American parents of a U.S. soldier slain in Iraq. Trump also said he wasn't ready to endorse Ryan, who had joined in that criticism.

Trump shifted course a few days later under heavy pressure from Republican leadership, but by then Nehlen had gotten a burst of national publicity.

Ryan responded with a blitz of radio appearances and added a pair of campaign stops the day before the election, determined to avoid the fate that befell House Majority Leader Eric Cantor, when the Virginia Republican lost a primary to a little-known tea party challenger.

Trump Takes Meetings at His New Jersey Golf Club

President-elect Trump interviewed more than a dozen candidates for his administration at his New Jersey golf club over the weekend, including Mitt Romney, Rudy Guliani, Chris Christie and Kansas secretary of state Kris Kobach, who has been tough on immigration, and others. (Published Monday, Nov. 21, 2016)

Ryan had other advantages, including widespread popularity in the district where he was first elected in 1998. Ryan had also worked hard to maintain those home ties, traveling back to Janesville as much as possible to be with his wife and three children.

Nehlen, an executive at a water filtration company, first made a splash with a web video of him riding a Harley-Davidson motorcycle, showing his tattooed arms. He challenged Ryan to an arm-wrestling match if he wouldn't debate him.

He ran well to Ryan's right, accusing Ryan of betraying Trump and favoring a "globalist agenda" of disastrous trade deals and porous borders. Nehlen attracted support from Sarah Palin and conservative provocateur Ann Coulter, with the latter appearing alongside Nehlen in the district the weekend before the election.