The city originated in 1793 as a military camp, then as a fortress built by the Cossacks to defend imperial borders and to assert Russian dominion over Circassia, a claim which Ottoman Turkey contested. In the first half of the 19th century, Yekaterinodar grew into a busy center of the Kuban Cossacks. It gained town status in 1867. By 1888 about 45,000 people lived in the city, which had become a vital trade center for southern Russia. In 1897 an obelisk commemorating the two-hundred-year history of the Kuban Cossacks (seen as founded in 1696) was erected in Yekaterinodar.
During the Russian Civil War (1917-1922) the city changed hands several times, coming successively under the control of the Red Army and of the Volunteer Army. Many Kuban Cossacks, as committed anti-Bolsheviks, supported the White Movement. Lavr Kornilov, a White general, captured the city on April 10, 1918, only to be killed a week later when a Bolshevik artillery shell blew up the farmhouse where he had set up his headquarters.
During World War II units of the German Army occupied Krasnodar between August 12, 1942 and February 12, 1943. The city sustained heavy damage in the fighting but was rebuilt and renovated after the war.
In the summer of 1943 the Soviets began trials, including of their own citizens, for collusion with the Nazis and for participation in war crimes. The first such trial took place at Krasnodar from July 14 to 17, 1943. The Krasnodar tribunal pronounced eight death sentences, which were summarily carried out in the city square in front of a crowd of about thirty thousand people.