Resurgent Republicans took control of the Senate on Tuesday night, expanded their hold on the House, and defended some of the most closely contested governors’ races, in a repudiation of President Obama that will reorder the political map in his final years in office.

Propelled by economic dissatisfaction and anger toward the president, Republicans grabbed Democratic Senate seats in North Carolina, Colorado, Iowa, West Virginia, Arkansas, Montana and South Dakota to gain their first Senate majority since 2006. Senator Mitch McConnell of Kentucky, a shrewd Republican tactician, cruised to re-election and stood poised to achieve a goal he has pursued for years — Senate majority leader.

An election that started as trench warfare, state by state and district by district, crested into a sweeping Republican victory. Contests that were expected to be close were not, and races expected to go Democratic broke narrowly for the Republicans. The uneven character of the economic recovery added to a sense of anxiety, leaving voters in a punishing mood, particularly for Democrats in Southern states and the Mountain West, where political polarization deepened.

The biggest surprises of the night came in North Carolina, where the Republican, Thom Tillis, came from behind to beat Senator Kay Hagan, and in Virginia. There, Senator Mark Warner, a former Democratic governor of the state, was thought to be one of the safest incumbents in his party, and instead found himself clinging to the narrowest of leads against a former Republican Party chairman, Ed Gillespie.