Gunfire erupted near the presidential palace in South Sudan's capital Juba on Friday, a day after a deadly clash dealt a new blow to a shaky peace deal in the world's youngest country.

President Salva Kiir and his deputy, former rebel leader Riek Machar, were both at the compound preparing to address the media when sporadic gunfire and artillery was heard outside for around 30 minutes.

There was confusion as the shooting died down, with Kiir telling reporters: "What is happening outside is something we cannot explain to you."

The fresh violence came a day after five soldiers were killed in a shootout with former rebels in Juba, just as the country prepares to mark its fifth anniversary of independence from Sudan on Saturday.

It was believed to be the first time the army and former rebels had clashed in the capital since both established positions there as part of the August 2015 peace agreement.

Army spokesman Lul Ruai Koang said the five soldiers, all loyal to Kiir, were killed and two others wounded in the shootout at a checkpoint in the city's Gudele neighbourhood.

Gudele was the scene of tribal massacres at the outbreak of the war in December 2013.