WASHINGTON—The midterm elections brought to a head a decadelong realignment of the U.S.’s major political parties, with Democrats winning contests in and around major cities while Republicans carried rural and small-town America.

The result—Democrats gained 27 GOP-held House seats to take the majority, with 17 races still undecided as of Wednesday evening, while Republicans added two seats to their Senate majority, with three still unsettled—was less a wave than the continuation of a slow-moving lava flow that began following...