Justin Hayworth / AP

Democrats conquered in the House on Tuesday night, picking up more than enough seats to secure a majority in the chamber. In Iowa alone, two GOP congressmen were unseated by women challengers.

But, at the end of the night, from under all the dust and rubble, emerged Steve King.

King, the Iowa Republican whose nativist rhetoric has brought a lot of unusual attention to the state’s Fourth Congressional District, didn’t exactly soar to victory: His opponent, Democrat J. D. Scholten came closer than any of King’s previous eight Democratic opponents, propelling a 19-point swing toward the Democrats from 2016. But it wasn’t enough.

That’s for two reasons: First, it’s a really Republican district, the reddest in the state. Donald Trump beat Hillary Clinton here by 27 percentage points in 2016. Second, King has been in Congress for 16 years. “People know him,” says the state Republican strategist David Oman. “Iowans love stability.”

King’s history of inflammatory remarks dates back more than a decade, but for most people, it was the “cantaloupes” comment that put him on the map. In 2013, King famously told Newsmax that for every child of undocumented immigrants “who’s a valedictorian, there’s another 100 out there who weigh 130 pounds and they’ve got calves the size of cantaloupes because they’re hauling 75 pounds of marijuana across the desert.” At the time, House Speaker John Boehner called the comments “deeply offensive and wrong,” but King stood by them.

But since then, King has amped up his incendiary comments. Last year, he tweeted in support of the far-right Dutch politician Geert Wilders, writing that “we can’t restore our civilization with somebody else’s babies.” (For this, King was praised by the former KKK grand wizard David Duke). In July, he retweeted a British white nationalist and self-described “Nazi sympathizer.” These actions sparked criticism from the GOP leaders House Speaker Paul Ryan and Iowa Republican Party Chairman Jeff Kaufmann, and prompted Scholten, a paralegal and former professional baseball player, to launch a campaign against him.

King was still expected to coast to victory in 2018. But that changed after the mass shooting in Pittsburgh in late October—when 11 Jewish worshippers were killed in an apparent anti-Semitic attack. Many on the left blamed President Donald Trump and other Republicans for stoking tensions with their nativist rhetoric. In the days after the shooting, King, who had just returned from a meeting with a member of a Nazi-linked party in Austria, was questioned about how his own comments could be contributing to violence.

The Republican Steve Stivers, chair of the National Republican Congressional Committee, denounced his rhetoric. “We must stand up against white supremacy and hate in all forms, and I strongly condemn this behavior,” Stivers wrote in a statement. Three major agriculture businesses subsequently said that they would no longer support King, and Scholten’s campaign received an immediate influx of cash.

For all that, though, King managed to hang on—albeit by his slimmest election margin ever. He beat Scholten 50 to 47 percent last night to win a ninth term in office.

How’d he do it? The residents of Northwest Iowa voted for him in spite of it all.

The district, which covers the northwest and north-central parts of the state, is mostly rural and overwhelmingly white, and King is a good ideological fit. Northwest Iowa, which has been referred to as the state’s “Bible belt,” is highly religious, and its voters are very socially conservative: They support King’s views on abortion and gun control. King also sits on the House Committee on Agriculture—farming is a major industry in the district—and has successfully sold himself as the enemy of big government.

“People know that he will sometimes pop off or say something that’s extreme, or even quite troublesome. But those other reasons cause them to stay with him,” Oman says. Plus, he says, many people point to how King presents himself in person and on the campaign trail. “One-on-one it’s really hard not to like the guy,” he adds. “He’s whip-smart, and he’s got a good sense of humor.”

That’s the sense I got from my interviews this summer with several King supporters. “He represents the morals and ethics of his district, not so much the outspoken voice,” said Bill Tentinger, a 69-year-old farmer and pork producer from outside Sioux City. Like most of King’s supporters, Tentinger wants his congressman to be pro-life, prioritize agriculture, and advocate for strict immigration laws. But still Tentinger sees some daylight between him and his congressman. “I’m not totally in step with Congressman King on his immigration comments,” Tentinger told me, noting that he wouldn’t support King “if we’re going to round up all the immigrants and ship them out of here.”

King may have escaped defeat, but going into 2020, he’ll have to tread carefully. Democrats came within spitting distance of the seat for the first time in years, and Scholten now has a state, and national, platform if he decides to run again. But while other scandal-plagued politicians might consider toning down their rhetoric to bolster their election chances, King probably isn’t one of them.

“There are districts where you can pretty much go out into the middle of the street and shoot someone, and you’ll get reelected,” said Steffen Schmidt, a political-science professor at Iowa State University, explaining King’s staying power. “Oops, I guess somebody else said that.”

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.