This is a fascinating article, pulling together recent research re-discovering older research.https://www.theatlantic.com/business/archive/2017/02/segregation-invented/517158/
What happened is somewhat prophetic for modern times, and a good contrary example. For about 25 years following the end of Reconstruction, Southern African Americans and poor whites formed a successful progressive third party movement called the "Fusion Party." Technically, African Americans were Republicans (which was still the party of Lincoln), a party white southerners refused to join. So they formed "fusion tickets" of Repblican African Americans and independent poor whites.
In the South, the Democratic Party remained the party of the elites (a role that became occupied by the Republican Party in the North). Threatened by economic populism, the Democrats used their control of the media to create a race issue and drive poor whites away from African Americans. They also unabashedly resorted to physical violence -- in one case forcing a Fusion mayor and board of Alderman to resign at gunpoint. Once back in power, the Democrats instituted a rigid Jim Crow segregation to prevent a similar interracial movement from occurring ever again.
(Eventually, poor southern whites would form a new progressive movement that would focus on economic progressivism, but would maintain the now ingrained tradition of racial hostility and discrimination. This is the Woodrow Wilson/Huey Long progressivism that most people are familiar with, and which created the idea that economic progressivism is in tension with racial justice.)