Democratic Sen. Jon Tester was declared Wednesday the winner of the Montana Senate race, scraping out a razor-thin victory against Republican Matt Rosendale despite a campaign onslaught by President Trump.
With 94 percent of precincts reporting, The Associated Press called the election for Mr. Tester with 49.34 percent of the vote, giving him a 1.54 percent lead over Mr. Rosendale, the state auditor. Libertarian Rick Breckenridge collected 2.87 percent.
Mr. Tester’s 7,000-vote lead came after a long night during which vote totals swung back and forth between the two candidates following the most expensive campaign in state history.
Mr. Trump targeted the two-term Democrat for defeat after he torpedoed in April his nominee for secretary of Veterans Affairs, Adm. Ronny Jackson, citing anonymous accusers who said he engaged in drunken and inappropriate behavior, which Mr. Jackson denied.
Mr. Trump headlined four rallies in Montana for Mr. Rosendale in a state that the president won by 20 percent in 2016, while Vice President Mike Pence and the president’s eldest son also made appearances on the Republican candidate’s behalf.
“We can’t have someone who will vote lockstep with Nancy Pelosi, Maxine Waters and Cryin’ Chuck [Schumer],” the president said at a rally on Saturday.
Mr. Tester swung back by tweaking Mr. Trump — at one point, he took out an ad welcoming the president to the state — and accusing Mr. Rosendale, who relocated from Maryland 20 years ago, of not being an authentic Montanan.
The Tester campaign regularly referred to Mr. Rosendale as an “East Coast developer” and accused him of pretending to be rancher despite not having an active cattle brand.
A third-generation Montanan, Mr. Tester won narrow victories in his previous two Senate races by playing up his folksy appeal: A self-described “dirt farmer,” he sports a crewcut and makes jokes about his missing three fingers, which he lost in a meat-grinder accident as a boy.
Mr. Tester also boasts one of the most moderate voting records among Senate Democrats, but he inflamed Republicans by voting against the Supreme Court nomination of then-Judge Brett M. Kavanaugh, who was ultimately confirmed.
The Montana Senate race shattered spending records with $60 million, breaking the $47 million mark set in Mr. Tester’s 2012 victory over former GOP Rep. Denny Rehberg.