Around 1626 Tajikistan comes under the rule of the Dzungarian Kalmuck's. It is part of China between 1758 and 1798 part of Kokand between 1798 and 1868. That year it is annexed by Russia The Russian rule wanes briefly after the Russian revolution of 1917 as the Bolsheviks consolidate their power and are embroiled in a civil war in other regions of the former Russian Empire. An an indigenous Central Asian resistance movement based in the Ferghana Valley, resists the bolsheviks, but is defeated in 1925. A year earlier Bukhara becomes part of the USSR. The USSR establishes Tajikistan as an autonomous Soviet socialist republic within Uzbekistan in 1924 and as one of the Soviet socialist republics in 1929.
The Republic of Tajikistan gains its independence during the breakup of the USSR in 1991. The first president is Rachmon Nabijev. Tajikistan promptly falls into a civil war from 1992-97 between old-guard regionally based ruling elites and disenfranchised regions, democratic liberal reformists and Islamists losely organized in a United Tajik Opposition (UTO). In 1992 Imomali Rachmonov becomes president. By 1997 the Tajik government and the UTO successfully negotiate a powersharing peace accord and implement it by 2000.
Both Tajikistan's presidential and parliamentary elections, in 1999 and 2000, are widely considered to be flawed and unfair but peaceful. Tajikistan is the only Central Asian country in which a religiously affiliated political party, the Nahzati Islomi Tojikiston (Islamic Renaissance of Tajikistan, NIT), is represented in parliament. Rachmonov is re-elected president as the candidate of the Hizbi Demokrati-Khalkii Tojikston (People's Democratic Party of Tajikistan, HDKT), and remains in a coalition with the UTO.