They were once a peaceful, spiritual people who collected works of art from all over the Alpha Quadrant, but their planet--Cardassia--lacked natural resources. The entire planet was stricken by famine and disease until the military took control of the government and expanded Cardassian borders, building fleets of warships and invading nearby worlds. Bajor--for one--was occupied for fifty years. Sometime before 2347 the Cardassians attempted to expand into Federation territory and war broke out, lasting around twenty years.
Shortly after the Cardassians withdrew from Bajor, a Federation presence was established aboard Terok Nor--renamed Deep Space Nine--to assist the Bajoran Provisional Government in rebuilding Bajor. However, the Federation officers discover a wormhole to the Gamma Quadrant. (Emissary), Roughly four months later, the Federation-Cardassian borders were redefined, with the two sides buffered by a demilitarized zone. However, the Cardassians harassed the Federation colonists in the DMZ who then retaliated by forming a resistance movement known as The Maquis.
Around the same time, the Obsidian Order--the Cardassian intelligence agency--began to gain power. However, it was destroyed when it allied with the Tal Shiar--the Romulan version--in a preemptive strike against the Dominion, a new threat from the Gamma Quadrant. (The Die Is Cast)
In January of 2372 (Stardate 49011), the Klingon Empire attacked the Cardassians believing the Detapa Council of Cardassia had been infiltrated by the Dominion. (The Way of the Warrior) The attack was led by General Martok who, it turned out, had been himself replaced by a shapeshifter--the leaders of the Dominion. (In Purgatory's Shadow)
Then, sometime between October 2373 and February 2374, with a Dominion attack on Deep Space Nine imminent, Gul Dukat announced the Cardassian Union's entry into the Dominion, shocking not only the Federation but most Cardassians as well. At the same time, Gul Dukat announced his ascension as leader of the Cardassian Union. Five days later, the Maquis were all slaughtered by the Dominion. (All but those on the Starship Voyager, that was lost in the Delta Quadrant at the time.)
The Cardassians (as members of the Dominion) captured DS9 (Call to Arms), but the Federation managed to plant the Bajoran wormhole with self-replicating mines, preventing the Dominion from sending in reinforcements.
Unfortunately for the Federation, Gul Damar discovered a way to disable the self-replication of the mines and completed the procedure and fired on the minefield seconds before operations chief Miles OBrien and his assistant Nog disabled the weapons in hopes to prevent just that. The USS Defiant attacked DS9 and managed to take it back when the Bajoran Prophets destroyed an entire Dominion fleet on its way through the wormhole. Gul Dukat was captured after his daughter Ziyal was killed by Gul Damar, who was then promoted to Legate. (Sacrifice of Angels)
Under the leadership of Damar, the Cardassian Union, along with the Dominion, continued to gain ground over the Klingon-Federation alliance, and even after Benjamin Sisko and Garak tricked the Romulans into breaking their nonaggression treaty with the Dominion and joining the alliance (In the Pale Moonlight) they still managed to keep the upper hand.
Damar, however, was not happy. While he had hoped that Cardassia joining The Dominion would strengthen their power, he felt that they were no longer in control of even their own planet, having to report to the Dominion flunky Weyoun and the Founders, and Cardassian troops were being sacrificed seemingly meaninglessly without his permission. Shortly after the Breen joined the Dominion--almost guaranteeing the Dominion's victory--Damar organised a revolt. A Cardassian named Broca became Legate and puppet ruler of Cardassia.
The revolt started out just as a small legion of troops headed by Damar, but during the final assault on The Dominion by the Federation-Klingon-Romulan alliance, Damar managed to get an open revolt started on Cardassia itself with the civilians joining in and the Cardassian fleet turned during battle and assisted the alliance. The Female Shapeshifter ordered every Cardassian on the planet killed.
With the Cardassian fleet helping the alliance and the rebel's attack on the Dominion headquarters on Cardassia, the Dominion surrendered, ending the Dominion War, but leaving Cardassia all but destroyed and with over 700 million dead on Cardassia alone.
In the Mirror Universe, the Cardassians formed an alliance with the Klingon Empire after destroying the Federation.