The phrase originated with post-bellum politicians using sectionalist animosities of the American Civil War to gain election in the postbellum North from the 1860s to 1880s. The phrase implied that members of the Democratic Party (which garnered much of their support from the "Solid South") were responsible for the bloodshed of the war and the assassination of Abraham Lincoln. Some candidates of the Republican Party as well a few candidates of other parties rivaling the Democratic Party used this notion to get elected to office, under the idea Democrats and Southerners are one and the same, and men should "vote as they had shot".
The term "bloody shirt" can be traced back to the aftermath of the murder of the third Caliph, Uthman in 656 AD, when a bloody shirt and some hair alleged to be from his beard were used in what is widely regarded as a cynical ploy to gain support for revenge against opponents. It also appears in a scene in William Shakespeare's Julius Caesar, in which Mark Antony waves Julius Caesar's toga to stir up the emotions of his fellow Romans. This comes from Caesar's historical funeral in 44 BC when Marc Antony showed the toga to the crowd during his funeral oration. In American history, it gained popularity with an apocryphal incident in which Benjamin Franklin Butler of Massachusetts, when making a speech on the floor of the U.S. House of Representatives, allegedly held up the shirt of a carpetbagger whipped by the Ku Klux Klan