* President declares state of emergency
* President offers to resign once new cabinet is formed* Two rival candidates for PM say they will work together
Kyrgyz President Sooronbai Jeenbekov declared a state of emergency in the capital Bishkek on Friday and ordered the military to end days of unrest, as supporters of rival political groups fought on the streets.
A Reuters journalist in the capital heard gunshots and saw demonstrators from rival groups throwing rocks and bottles at each other and scuffling. One opposition politician was reported to have been wounded.
"Today we are witnessing a real threat to our statehood," Jeenbekov said, explaining the move, a day after the Kremlin said it needed to prevent chaos in the former Soviet republic.
Earlier the president had said he was ready to resign once a new cabinet was appointed - which could happen on Saturday, when parliament plans to convene in his residence, according to a deputy speaker quoted by local news website Akipress.
The country is facing a power vacuum, with opposition groups quarrelling among themselves since seizing government buildings and forcing the cancellation of results from Sunday's parliamentary election which they denounced as fraudulent.
Two leading opposition figures reached an agreement to join forces on Friday, and won the backing of Jeenbekov's predecessor as president, Almazbek Atambayev. But their followers and followers of other groups held rival rallies, which politicians said posed a danger of violence.
Jeenbekov's office said in a statement the state of emergency, including a curfew and tight security restrictions, would be in effect from 8 p.m, on Friday until 8 a.m. on Oct. 21.
His order did not say how many troops would be deployed but they were instructed to "take the situation under control" and use military vehicles, set up checkpoints, and prevent armed clashes.
However, a local NGO said the order required a confirmation from parliament.
Russia has described the situation in Kyrgyzstan, which borders China and hosts a Russian military base, as "a mess and chaos".
The crisis tests the Kremlin's power to shape politics in its former Soviet sphere of influence, at a time when fighting has erupted between Armenia and Azerbaijan, and Belarus is also engulfed in protests.
The opposition is divided between 11 parties which represent clan interests in a country that has already seen two presidents toppled by popular revolts since 2005.
Rival candidates for the premiership Omurbek Babanov and Tilek Toktogaziyev joined forces on Friday, with Toktogaziyev agreeing to serve as Babanov's deputy. They were backed by four parties, local news website 24.kz reported.
They were joined at a rally in Bishkek by the former president Atambayev. A few thousand followers chanted "I am not afraid" and "Kyrgyzstan" to the rhythmic beating of large drums.
Followers of another candidate, Sadyr Zhaparov, also numbering a few thousand, held a demonstration nearby. Some of Zhaparov's supporters later rushed into the square, leading to scuffles between the rival groups until the Babanov and Toktogaziyev supporters withdrew.
News website Akipress said Toktogaziyev was rushed to a hospital with blunt head trauma after the confrontation where he then regained consciousness and was in stable condition.
Separately, an aide to Atambayev said a shot had been fired at his car which did not wound anyone.
Jeenbekov's allies swept Sunday's parliamentary vote in the official results that have now been discarded. They have kept a low profile as the opposition parties have taken to the streets. Western observers said the election was marred by credible allegations of vote-buying.
So far, veteran officials who supported the revolt have been in control of the security forces. On Friday, self-appointed provisional heads of the interior ministry and the state security service left their respective buildings and handed over the leadership to their deputies. The two state bodies said the move was meant to ensure security forces remained apolitical.