Almost immediately after independence, Tajikistan was plunged into a civil war that saw various factions fighting one another. These factions were supported by foreign countries including Afghanistan, Iran, Pakistan, Uzbekistan and Russia. Russia and Iran focused on keeping peace in the warring nation to decrease the chances of U.S. or Turkish involvement. Most notably, Russia backed the pro-government faction and deployed troops from the Commonwealth of Independent States to guard the Tajikistan-Afghan border. All but 25,000 of the more than 400,000 ethnic Russians, who were mostly employed in industry, fled to Russia. By 1997, the war had ended after a peace agreement between the government and the Islamist-led opposition, a central government began to take form, with peaceful elections in 1999.