* U.N. envoy appeals to leaders for calm
* President declares curfew in Juba
* South Sudan has struggled since 2011 independence
South Sudan's President Salva Kiir declared a curfew in the capital Juba on Monday after overnight clashes between rival factions of soldiers followed months of tension between Kiir and his sacked deputy.
Kiir blamed soldiers loyal to Riek Machar, who was dismissed as vice-president in July, for starting the fighting in the capital that extended into Monday morning before easing.
The two men are from rival ethnic groups which have clashed in the past. Machar has said he wants to run for president.
Flanked by ministers and wearing combat fatigues rather than civilian clothes, Kiir declared an overnight curfew in Juba effective from Monday. It will run each night from 6 p.m. to 6 a.m.
Kiir said the fighting, which he descibed as an "attempted coup", broke out after an unidentified person had fired shots in the air near a ruling party conference.
"This was followed later by an attack at the SPLA headquarters near Juba University by a group of soldiers allied to the former vice-president Dr Riek Machar and his group. These attacks continued until this morning," he said.
"However, I would like to inform you, at the outset, that your government is in full control of the security situation in Juba.".
Gunfire and blasts were heard through the night around Juba, intensifying on Monday morning. Fighting mostly susbisided by midday, with witnesses reporting sporadic gunfire in some areas and a heavy military presence in the city.
Kenyan airlines Fly540 and Kenya Airways suspended flights indefinitely to Juba after the airport closed due to fighting.
The government has struggled to establish a functioning state since declaring independence from Sudan in 2011 to become Africa's newest nation.
Kiir had dismissed Machar after mounting public criticism at the government's failure to deliver better public serices in the oil-producing nation, which is the size of France but barely has any tarmac roads.
Clashes were concentrated at two military bases, the Bilpam barracks north of the airport and the Jebel barracks south of Juba, where the presidential guard is based, residents said.
A U.N. spokeman said about 800 civilians had taken shelter in a U.N. compound near the airport. Speaking by telephone, he said seven people had been treated for gunshot wounds, including a two-year-old boy.
A Reuters reporter saw one man with blood all over his legs being carried by civilians along the largely deserted streets in the direction of the hospital.
CALLING FOR RESTRAINT
The fighting is the latest setback for one of Africa's poorest states. Oil production, South Sudan's main source of revenue, was shutdown for 15 months till April because of a row with Sudan, which hosts the main export oil pipeline.
"I urge all parties in the fighting to cease hostilities immediately and exercise restraint," U.N. Special Representative of the Secretary-General Hilde Johnson said. "I have been in touch regularly with the key leaders to call for calm."
Jok Madut Jok, chairman of South Sudan's Sudd Institute think tank, also said troops loyal to Machar were to blame.
"Riek Machar is not new to this kind of militaristic avenue to power," he said by telephone from Juba.
After accepting his dismissal at the time, Machar has since accused the president of acting like a dictator. Kiir said last week that some "comrades" where threatening to drag the nation back to a period in 1991 when South Sudanese ranks were split.
The fighting has revived memories of the factionalism in the 1990s within the Sudan People's Liberation Movement - the group that fought Sudan's army in the north for two decades. Machar led a splinter faction and south-south clashes erupted.
Machar is from the Nuer tribe which has fought in the past with South Sudan's dominant Dinka tribe, to which Kiir belongs.
Critics say the new nation suffers the same ills as old Sudan, namely rampant corruption, poor public services and repression of government opponents and media.
The Twitter account of the U.S. Embassy in South Sudan denied rumours Machar had taken refuge at the base and said the mission was monitoring the security situation.
"The majority of citizens are yearning for peace," said Atem Yak Atem, a former deputy minister of information who now runs a media consultancy. "People are calling for a negotiated settlement among the politicians."