(CNN) Democratic Sen. Jon Tester will win a third term in the Senate, CNN projects, outlasting millions of outside spending and an intense focus on the race from President Donald Trump.
Tester was widely seen early in the cycle as a vulnerable Democrat due to the fact Trump won the state by 20 points just two years ago. But Tester's unique brand as a farmer from Big Sandy and personal connection to the state provided a contrast to Republican Matt Rosendale, whose ties to the state were constantly in question.
Tester, like other Democrats running in red states, routinely pledged throughout the campaign to work with Trump when needed, even running TV ads touting his work with Trump.
"Washington is a mess but that is not stopping me from getting bills signed into law by President Trump," Tester said in his first campaign ad.
That relationship with Trump frayed, though, after Tester led the charge against Ronny L. Jackson, the former White House physician who Trump picked to lead the Department of Veterans Affairs. Tester, the top Democrat on the Senate committee that oversaw Jackson's confirmation, accused Jackson of handing out prescriptions "like candy" on foreign trips, accusations that eventually sunk his nomination.
The process irked Trump, and the President traveled to the state four times this campaign season to rally against Tester and tout Rosendale. During the events, Trump particularly hammered the Democrats' handling of the Jackson confirmation.
"I can never forget what Jon Tester did to a man that's of the highest quality," Trump said in October. "What (Tester) did was unfair, what he did was vicious, what he did was ... almost, almost, if this is believable, worse."
Tester attacked Rosendale as an out-of-state developer by highlighting his ties to Maryland. Those attacks were helped by Rosendale's competitive and negative primary, which provided the Tester campaign with plenty to use against the Republican. Tester closed the campaign by attacking Rosendale as "all hat, not cattle."