Armenia will leave a Russia-led military alliance, Prime Minister Nikol Pashinyan confirmed Wednesday, accusing members of the bloc of plotting with bitter rival Azerbaijan to start a war against them.

Pashinyan has for months accused the Kremlin’s Collective Security Treaty Organization (CSTO) of failing to protect Armenia from resurgent Azerbaijani aggression, threatening to leave the bloc if Moscow did not provide greater assurances and trying to cleave more closely to the United States and European Union.

Since the collapse of the Soviet Union, Armenia and Azerbaijan have fought two wars over the breakaway Nagorno-Karabakh region, which Azerbaijan reclaimed in full by force in September. Russia has traditionally allied with Armenia, but their relations have soured in recent months while Moscow’s ties to Azerbaijan have deepened.

Speaking to parliamentarians in the capital Yerevan, Pashinyan said his country had “frozen” its participation in the CSTO and would leave the bloc at a time of Armenia’s choosing.