The flag that’s currently being flown as “the Confederate Battle Flag” is based on a flag used by the Army of Tennessee beginning in January 1864. There was also a similar naval flag.
This was based on a battle flag used by Robert E. Lee’s Army of Northern Virginia from March 1861, because the official Confederate Flag at the time was too-easily confused for the United States Flag. William Miles’ design had previously been rejected by the The Committee on the Flag and Seal for looking “like a pair of suspenders,” but was chosen as a battle flag by General Pierre Beauregard anyway. This was square rather than rectangular. It had one star for each state of the Confederacy. Other Confederate generals during the war chose different battle flags, but the one became used by armies in the east and was the best-known.
In May, 1863, the Confederacy adopted the “Stainless Banner” as its new national flag, with the square battle flag as the union on a white field.
There was a third version of the flag, adding a red bar on the right, but it was barely-used, since Lee surrendered only a few weeks later.
Within a decade after the end of the war, the United Confederate Veterans and the United Daughters of the Confederacy were using the square battle flag in war memorials. The original intent of using the battle flag instead of the Stars-and-Bars or Stainless Banner was to honor the soldiers rather than the politicians. Originally, the UCV tried to promote the square battle flag of the Army of Northern Virginia over the rectangular flag of the Army of Tennessee, but the rectangular design, which looked more like a national flag, became more popular.
In the ensuing years, the flag was adopted by the Kappa Alpha Order, a fraternity founded at the university that made Robert E. Lee its president. This began with their organizing war memorials, but the fraternity soon began using it in totally unrelated contexts. It was in the hands of students at southern colleges that the flag appeared at the convention of the States’ Rights Party in July 1948, which ran on a platform of maintaining Jim Crow laws and racial segregation. In November 1948, the UDC put out a statement condemning the use of the battle flag “in certain demonstrations of college groups and some political groups,” and southern states passed laws against what they considered “desecration” of the Confederate battle flag by using it as a decoration on disposable baubles.
Unfortunately, the flag also was adopted by White supremacist groups, such as the Ku Klux Klan. Just as the UDC feared when “the flag fad” began in 1948, many people now associate it more with reactionary politics than with its use from the 1870s to the 1940s almost exclusively in war memorials.
I can attest that it is now also used as a symbol of White southern culture more broadly, in places thousands of miles away from any Civil War battlefield.