KHOJALY, Azerbaijan (Reuters) - Russia shut down a military base in Azerbaijan on Wednesday where nearly 2,000 of its troops had been deployed, after Azeri forces captured the area last year despite a two-year Russian mission to prevent war between Azerbaijan and Armenia.

A total of 1,960 Russian peacekeepers had been housed in 10 barracks at the base in Khojaly, a town in the Karabakh region. Despite the deployment, Azerbaijan recaptured Karabakh in a lightning offensive last September, prompting an exodus of 100,000 ethnic Armenians who had enjoyed de facto independence since breaking away in the 1990s in the first of two wars between the South Caucasus neighbours.

"The presence of Russian peacekeepers made it possible to establish peace on Azerbaijani soil," Russian Colonel General Yevgeny Nikiforov said at the departure ceremony.

Azerbaijan's chief of the general staff, Colonel General Kerim Valiyev, said Russia had made "every effort to establish peace in the Karabakh economic region" and bring decades of conflict to an end.

Armenia has a very different take on Russia's role. It has accused Moscow of failing it by doing nothing to prevent Azerbaijan from taking Karabakh by force and conducting what it calls ethnic cleansing, something Azerbaijan denies.

Armenia has suspended its participation in the Collective Security Treaty Organisation, a defence grouping of former Soviet states that is dominated by Russia.

Armenia was not represented at Wednesday's ceremony, where folk dances and patriotic songs were performed and Russian troops departed to the strains of a military band.

Nikiforov said the Russian force could take credit for providing humanitarian assistance, clearing more than 30,000 explosive devices, returning more than 110 prisoners of war and arranging the return of more than 1,900 fallen soldiers to the respective sides.

"The Russian military completed the task assigned to them," he said.

(Reporting by Nailia Bagirova, Writing by Mark Trevelyan,; Editing by Ros Russell)

By Nailia Bagirova