Missouri Attorney General Josh Hawley, a Republican, will unseat Democratic Sen. Claire McCaskill in one of the year's most hotly contested races, NBC News projects.

The result is a big blow to Democrats, who were projected to stay in the Senate minority. Republicans already had a thin 51-49 majority going into Election Day.

Hawley aligned himself with Trump and consistently knocked McCaskill as a liberal elitist with close ties to Washington. McCaskill, like other Democrats seeking re-election in Trump states, searched for middle ground on the question of working with the president.

Polls showed the Missouri race as a toss-up before the election. Nearly $55 million in outside spending poured into the race, according to the latest reports, in addition to almost $40 million that the candidates each raised.

Hawley's tenure as Missouri's attorney general was brief and chaotic, and it eventually emerged as a campaign issue. But the situation in his office was largely overshadowed by a national agenda that took center stage in the race, including issues like tariffs, immigration and Justice Brett Kavanaugh's controversial confirmation to the Supreme Court.

On health care, Hawley was party to a lawsuit that would unravel the Affordable Care Act, including its protections for people with pre-existing conditions. He promised, however, that he would approve ways to cover pre-existing conditions outside the parameters of Obamacare.