Armenian Prime Minister Nikol Pashinyan has warned of an attempted military coup, after the country's armed forces said he and his cabinet must resign.
The army "must obey the people and elected authorities," he told thousands of supporters in the capital Yerevan. His opponents held a rival rally.
The military's top brass was angered by the PM's sacking of a commander.
Mr Pashinyan has faced protests after losing last year's bloody conflict with Azerbaijan over a disputed region.
Nagorno-Karabakh is an enclave internationally recognised as part of Azerbaijan but which had been controlled by ethnic Armenians since a 1994 truce.
During the six-weeks of fighting late in 2020, Azerbaijan not only recaptured areas around the enclave but also took the key town of Shusha inside it.
Under the Russian-brokered deal that emerged shortly afterwards, Azerbaijan keeps the areas it has captured. Hundreds of Russian peacekeepers are deployed in the disputed area.
What is Pashinyan's defence?
In a Facebook video post on Thursday, Mr Pashinyan, 45, said he considered a statement by the military earlier on Thursday an "attempted military coup".
He urged his backers to gather on Republic Square in the heart of Yerevan, and was seen shortly afterwards surrounded by thousands of supporters on the streets of the city.
"The army is not a political institution and attempts to involve it in political processes are unacceptable," he told his supporters.
But he invited the opposition to hold talks on how to resolve the crisis, stressing that any change in power must take place "only through elections".
Meanwhile, opposition supporters staged a rival demonstration in the capital, insisting that Mr Pashinyan must go.
Vazgen Manukyan, one of the opposition leaders, urged the crowds to start blocking the parliament, saying lawmakers should be brought in to vote for Mr Pashinyan's dismissal.
"Get ready, we will stay here all night and will block the street with barricades," he was quoted as saying by the Armenpress news agency.
Mr Pashinyan, a former journalist, took office after leading a peaceful 2018 revolution in the post-Soviet state.
He has recently survived several attempts in parliament to dismiss him.
Tea and biscuits, not a real threat to the authorities
By Ilya Barabanov, BBC Russian, Yerevan
This is the first time since the end of the war in Nagorno-Karabakh that Nikol Pashynian called on his supporters to come out on to the Republic square in the centre of the Armenian capital.
While the prime-minister's supporters were gathering, the opposition assembled a rival rally nearby - in the Freedom square. The opposition's plan was to later head to parliament building, where some of the factions were attempting to start an emergency session to approve a call for an early general election.
Neither of the rallies managed to gather considerable numbers. The opposition tried to set up some tents next to the parliament but their efforts were not that impressive, considering there were fewer than a thousand people in the vicinity.
Around ten tents, a few wood-burning stoves, some makeshift tables with tea and biscuits for the protesters did not look like the sort of threat that might force the authorities to make any concessions.
Opposition supporters said they were setting up barricades with rubbish bins. But the police had blocked all traffic in the area and kept the parliament building cordoned off, while not engaging with the protesters. A few hours later the police started leaving the area.
What are the military's accusations?
The General Staff of Armenia's military issued its statement soon after Mr Pashinyan had dismissed armed forces deputy chief Tiran Khacharyan.
Mr Khacharyan had ridiculed Mr Pashinyan's claims that Russia-supplied Iskander missiles failed to hit targets during the fighting in Nagorno-Karabakh.
Russia has a military alliance with Armenia and an army base in the country, but it did not intervene during the conflict. It also has close ties with Azerbaijan and has sold weapons to both countries.
Azerbaijan was openly backed by Turkey during the fighting.
In its statement, the military's top brass said "the prime minister and the government are no longer able to make reasonable decisions", according to the Armenpress.
"For a long time, the Armenian armed forces were patiently tolerating the 'attacks' by the incumbent government aimed at defaming the armed forces, but everything has its limits."
The statement accused Mr Pashinyan's government of making "serious mistakes in foreign policy" that resulted in the Armenian state being on the verge of destruction.
Soon after the statement was issued, Mr Pashinyan also sacked armed forces chief Onik Gasparyan.
It is unclear if the two fired top commanders have left their posts, as President Armen Sargsyan first needs to approve the prime minister's orders.
What has the reaction been?
Mr Sargsyan - who holds a largely ceremonial role in the country - urged all sides to "show restraint and common sense".
Two Armenian opposition parties backed the military's demand for Mr Pashinyan and his government to resign, calling on the prime minister to avoid a civil war.
In a statement, Armenia's National Security Service urged all sides to "refrain from actions that threaten national security".
Turkish Foreign Minister Mevlut Cavusoglu said: "We strongly condemn the coup attempt in Armenia."
Russia has expressed concern and called for calm.
The US called on "all parties to exercise calm and restraint and to de-escalate tensions peacefully".