SYDNEY (Reuters) - Papua New Guinea's investment risk has worsened after a failed mutiny, with Standard & Poor's revising its outlook to negative on Friday and warning that the political crisis, with two competing prime ministers, was impeding the resource-driven economy.

Early Thursday, up to 20 soldiers raided the main army barracks in the capital Port Moresby, seized their chief commander and placed him under house arrest, and announced a new military commander.

The rebels demanded the reinstatement of deposed prime minister Sir Michael Somare, but by Thursday night the mutiny had failed and the government of Prime Minister Peter O'Neill was back in control.

"Political settings in PNG have weakened following the detention and later release of the defense force chief," said S&P in revising down the outlook for South Pacific nation, whose 'B+/B' sovereign credit rating was affirmed.

"We would lower the ratings if the political friction remains unresolved, leading to a loss of donor support and investment required to diversify the economy and buttress PNG's government finances and external position."

U.S. oil giant ExxonMobil is in the process of developing a massive $15.7 billion liquefied natural gas plant, the country's biggest-ever resource project.

A country of 6.5 million people, Papua New Guinea has vast mineral wealth although 85 percent of its people live a subsistence village life.

Port Moresby is plagued by lawless and often violent "raskal" gangs of youths and the country has a history of political and military unrest.

An army mutiny in 1997 overthrew the government after it employed mercenaries to try to end a long-running secessionist rebellion on the island of Bougainville, home to a big copper mine.

On Friday, the rebels were reportedly inside an army barracks on the outskirts of Port Moresby, with the government saying they would be dealt with.

Papua New Guinea has been in the grip of a political deadlock for months, with O'Neill and Somare both claiming to be the legitimate prime minister.

O'Neill took office in August after Somare was ruled ineligible as a member of parliament due to illness and absence from parliament. Somare was in Singapore receiving treatment for a heart condition.

But the Supreme Court in December ruled Somare be reinstated as a member of parliament. O'Neill rejected the ruling and parliament again voted him prime minister, leaving the country with two competing leaders.

"The unresolved claims to the prime minister position underlie the vulnerabilities associated with the country's fragmented political structure," said S&P.

(Reporting by Michael Perry; Editing by Lincoln Feast and Richard Borsuk)