Azerbaijan came under Russian rule after the Persian-Russian wars of 1804-1813. The country gained independence for a short period, however, towards the end of the First World War. After the collapse of the Russian Empire in 1917, Azerbaijan, together with Armenia and Georgia formed the short-lived Transcaucasian Democratic Federative Republic. When this republic ended in May 1918, Azerbaijan declared independence as the Democratic Republic of Azerbaijan on May 28, 1918, as the first modern and secular parliamentary republic in the Muslim World. However, the Red Army occupied the territory and annexed it to the newly formed Soviet Union and the Azerbaijan Soviet Socialist Republic was founded on April 28, 1920. 