On Tuesday, NBC and WSAZ reported that Kentucky voters denied GOP governor Matt Bevin a second term, electing Democratic Attorney General Andy Beshear in a furiously contested race that captured nationwide attention.

Beshear, the son of a popular former Democratic governor, spent a large part of his term as attorney general challenging Bevin’s policies, from state benefit cuts to abortion restrictions, setting up a fierce rivalry that came to a head in the gubernatorial race.

Advertisement:

Bevin, the first Republican governor in Kentucky to preside over unified party control of the legislature, has had a controversial and bitter tenure in office, waging war against teacher pensions and picking fights with members of his own party. Polls consistently ranked him among the least popular governors in the United States, and some observers speculated the race could inform the state of play in next year’s Senate election, where Majority Leader Mitch McConnell is seeking re-election.

But while these numbers made the race close, Kentucky is an extremely conservative state, having backed President Donald Trump by nearly 30 points. To blunt his unpopularity, Bevin tied himself as closely as possible to the president, who held multiple campaign events to promote his re-election including a rally the night before the election.

The result is a massive defeat for Republicans — and a serious humiliation for Trump.