WEST FARGO, N.D. — Representative Kevin Cramer, who latched onto Donald J. Trump even before he was president and never let go, ousted North Dakota’s incumbent Democratic senator, Heidi Heitkamp, on Tuesday, flipping a key seat that was vital to Republican efforts to hold the Senate.
In an election that largely became a referendum on the president, voters here cast out the centrist Ms. Heitkamp, replacing an increasingly rare moderate voice in the Senate with a proud and fiercely conservative partisan.
Mr. Cramer’s win affirmed the state’s support for Mr. Trump, who swept North Dakota in 2016 with a 36-percentage-point margin of victory. Eager to defeat Ms. Heitkamp, considered the Democrats’ most vulnerable senator, the president rallied here three times in support of the congressman in an effort to energize the Republican base.
Ms. Heitkamp delivered her concession speech in Fargo, N.D.CreditHilary Swift for The New York Times
On the campaign trail, Mr. Cramer painted Ms. Heitkamp as a liberal extremist out of touch with the state’s values, and positioned himself as a steadfast supporter of the president’s agenda. He offered a stark contrast between her voting record and his own — he has voted with Mr. Trump’s position almost 99 percent of the time.
[Make sense of the country’s political landscape with our newsletter.]
“Can you imagine going home and telling your wife, ‘I’ve been faithful to you 55 percent of the time?’” Mr. Cramer told a local radio show in April. “Are you kidding me? Being wrong half the time is not a good answer.”
Ms. Heitkamp tried to fight back by touting her willingness to reach across the aisle, coaxing voters to embrace moderation and compromise, betting that voters, weary of biting partisanship and division, would reject demands for ideological purity and endorse her brand of centrism. The bet has historically been a safe one in North Dakota.
“We were famous for ticket splitting and judging the individual on their own merits,” said former Representative Earl Pomeroy, a Democrat who served in the House from 1993 to 2011 and campaigned in support of Ms. Heitkamp.
Live U.S. Senate Election Results
See live U.S. Senate results and maps.
Pollsters were already forecasting an uphill battle for the incumbent senator, facing national political headwinds and an environment more open to unapologetic partisanship. But her political fate may have been sealed last month when she voted against Justice Brett M. Kavanaugh’s confirmation. The vote yielded her a $12 million fund-raising windfall from Democrats across the country and buoyed her get-out-the-vote effort.
But it earned her scorn from many of the Republican-leaning voters she needed.
There were unforced errors from her campaign, too. Ms. Heitkamp had touted her advocacy for women and invoked her own mother’s experience with sexual assault after the Supreme Court vote, taking a swipe at Mr. Cramer, who called the #MeToo movement a “movement toward victimization.” But she was forced to publicly apologize after her staff released the names of survivors of sexual assault in a campaign advertisement without their permission.
In the days ahead of the election, Ms. Heitkamp was sanguine. She had been doubted before and prevailed, she said, referring to her 2012 victory in which she eked out a win by 3,000 votes. But she also acknowledged that there were voters in the state she had never been able to win over.
“I think people who are going to vote straight Republican, they aren’t people who will ever be persuaded one way or the other,” she said in an interview after a rally Monday night. “They’ve joined a team.”