Despite being the target of the president’s personal vendetta, incumbent Sen. Jon Tester (D-MT) won another term in a state that values its independent streak.

Tester beat Republican Matt Rosendale by about 5,000 votes, after remaining ballots were tallied on Wednesday.

It’s an accomplishment for the incumbent Democrat after President Donald Trump won Montana by 20 percentage points in 2016 (even as the state elected Democratic Gov. Steve Bullock). Tester was among 10 Senate Democrats running in heavily red states who the Republican Party was eager to knock off and avoided the fate of Claire McCaskill (D-MO), Joe Donnelly (D-IN), and Heidi Heitkamp (D-ND) who were easily defeated by Republicans.

Perhaps more so than the others, Trump set his sights on Tester after he raised concerns about the nomination of White House doctor Ronny Jackson to lead the Department of Veterans Affairs, allegations that eventually sunk the nominee.

In numerous visits to the state, one frequented by Donald Trump Jr. as well, the president sought to remind voters of Tester’s actions, famously declaring in an April rally that he knew things about Tester that would end his career. It was never clear what Trump meant by that and the barrage of attacks from the president were not enough to lead to a loss for Tester.

He defeated Rosendale, currently the Montana state auditor, whose Maryland accent typified the kind of criticism he earned from Tester, who was born and raised in Montana. Labeling him an as “East Coast developer,” Tester campaigned on protecting a mandate that health-care insurers cover pre-existing conditions and the preservation of federal public lands, all while showcasing his folksy farmer vibe, complete with a hand mangled in a meat-grinder accident when he was a child.