(CNN) -- South Sudan's military has quashed an attempted coup, President Salva Kiir said Monday, after heavy gunfire gripped the capital of Juba.
Dressed in fatigues and flanked by government officials, Kiir blamed soldiers loyal to his sacked deputy Riek Machar for starting the fighting.
In a televised address, he said the government was in full control of the capital, and announced a nighttime curfew.
"They tried to carry out a coup -- a so-called coup d'etat -- but they have failed," Kiir said.
"All the people who were involved in this will be arrested."
He said a nighttime curfew "for the sake of security and safety of our citizens" would run from 6 p.m. until 6 a.m.
A move by Kiir to dismiss his Cabinet in July has further inflamed deep-running tensions between Kiir's Dinka community and Machar's Nuer community.
Earlier, heavy gunfire was reported in the city, government official Peter Biar Ajak said.
The U.S. and British embassies in Juba urged their citizens via Twitter to stay indoors and be cautious.
"Gunshots/artillery fired over the past few hours in several locations in Juba," the U.S. Mission in Juba tweeted.
In a statement on its Facebook page, the U.S. Embassy said that while there was now a lull in violence, it continued to receive reports of sporadic gunfire in parts of the city, particularly near Juba University. It said the airport was not operational.
It recommended that U.S. citizens use "caution at this time," adding that travel in Juba was not currently safe.
It also reiterated an earlier tweet denying Machar had taken shelter there.
"We take this opportunity to reaffirm our earlier message that no political or military figures have taken refuge within the U.S. Embassy," the mission said.
In a separate statement, the embassy said it was "deeply concerned at the recent outbreak of armed violence" in Juba and echoed calls from the U.N. envoy there for all parties to "cease hostilities immediately and exercise restraint."
The British Embassy has issued an alert advising British nationals against all nonessential movement in parts of the country.
South Sudan formally split from Sudan in 2011, after decades of conflict. Numerous armed groups remain active in the oil-rich country.
Women, children flee to U.N. compound
Hundreds of people, mainly women and children, have taken shelter at the U.N. compound near the airport and at a U.N. house in the city, the United Nations Mission in South Sudan (UNMISS) said.
"We hope the security situation in Juba will quickly normalize to enable the civilians to return very soon to their residential areas. To that end, UNMISS calls on all parties to show continued calm and restraint," it said in a statement.
It also denied "any suggestion that the U.N. Mission is harboring any key political or military figures."
CNN's Marie-Louise Gumuchian, Samira Said and Saad Abedine contributed to this report.