Montana Democratic Sen. Jon Tester prevailed in a tight re-election race, securing a third term in a state President Donald Trump carried by 21 points in 2016.

With 91 percent of precincts reporting, Tester led Republican state Auditor Matt Rosendale 49 percent to 48 percent when The Associated Press called the race Wednesday. Libertarian candidate Rick Breckenridge, who had appeared to endorse Rosendale last week, finished with just under 3 percent.

First elected in 2006, Tester has never won more than 50 percent of the vote in his previous Senate races. But his personal brand once again helped him overcome partisan leanings in Big Sky Country.

Tester isn’t as conservative as some other red-state Democrats who were up for re-election this year. He voted against both of Trump’s Supreme Court picks and raised questions about the president’s nominee for Veterans Affairs secretary, which provoked Trump’s ire. Democrats, though, cast that as an example of the senator’s independence.

Tester looked to be in better shape than many of his red-state Democratic colleagues for much of this race, but the contest began to tighten after the GOP deployed Trump to Montana for multiple rallies to help nationalize the campaign.