SOUTH Sudan's President Salva Kiir has declared a curfew in the capital Juba after what he claimed was an attemped coup resulted in overnight clashes between rival factions of soldiers.

Mr Kiir blamed soldiers loyal to Riek Machar, who was dismissed as vice-president in July, for starting the fighting in the capital that lasted until yesterday morning before easing.

The two men are from rival ethnic groups which have clashed in the past and Mr Machar has said he wants to run for president.

Flanked by ministers and wearing combat fatigues rather than civilian clothes, Mr Kiir declared an overnight curfew in Juba, running each night from 6pm to 6am.

Mr Kiir said the fighting, which he described as an "attempted coup", broke out after an unidentified person had fired shots in the air near a ruling party conference.

But he added: "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 yesterday morning. Fighting mostly susbisided by midday, with witnesses reporting sporadic gunfire in some areas and a heavy military presence in the city.

The government of South Sudan has struggled to establish a functioning state since declaring independence from Sudan in 2011 to become Africa's newest nation.

Mr Kiir had dismissed Mr 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.

Yesterday's 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 UN spokeman said 800 civilians had taken shelter in a UN compound near the airport. He said seven people had been treated for gunshot wounds, including a two-year-old boy.

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.

UN Special Representative of the Secretary-General Hilde Johnson said "I urge all parties in the fighting to cease hostilities immediately and exercise restraint 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, said troops loyal to Mr Machar were to blame.

After accepting his dismissal at the time, Mr Machar has since accused the president of acting like a dictator.

Mr Kiir said last week 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.

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.