How did the US Republican party flip from the party of the North to having a strong Southern base?

by SierraPapaHotel

This is treading close to the "no politics" rule, but I'm asking here precisely because I want a non-political answer.

As stated by Wikipedia

In the [Republican] Party's infancy, its base consisted of Northern white Protestants and African Americans nationwide.

In 2016, The New York Times noted that the Republican Party was strong in the South, the Great Plains, and the Mountain States.

How/when did this flip occur? What events lead to the party of the industrial North becoming the party of the rural south? Conversely, how did the Democratic party, which was previously conservative, become more liberal?

voyeur324

/u/Samuel_Gompers has arisen from the grave to inform you of the following:

/u/erissays has previously answered Did the US political parties switch political platforms?

All these answers (and more!) can be found in the subreddit's North American History FAQ page.

EDIT: More answers are always welcome, of course. This question and others like it come up fairly often.