About 40 officers were also said to have been arrested.
Antonio Indjai, the newly-designated army chief, said on national radio that the show of force by mutinous solders was purely a military problem and the army remained submissive to political power.
"The Guinea-Bissau armed forces would like to make the point that events which occurred this Thursday morning are a purely military problem and do not concern the civil government.
"The army reiterates its attachment and its submission to political power. Military institutions remain, and will remain, submissive to political power."
Show of support
National radio broadcasts were interrupted by military music - often a signal that a coup is taking place - and hundreds of demonstrators gathered outside the government headquarters after news of the arrest spread, to demand the prime minister's freedom.
Indjai threatened to kill Gomes - whose nickname is "Cadogo" - in a public radio broadcast if his supporters continued to press for his release.
"We ask you to stop anything that attracts a crowd in the streets. If you do not do this, we will have to kill Cadogo," the general said.
|Army chief Induta was being held at an army base after his detention [AFP]
Indjai said Jose Zamora Induta, the army chief of staff, and Gomes "must pay for all the crimes they have committed".
During his news conference, Indjai was accompanied by Bubo Na Tchuto, a former head of the navy, who had earlier left a UN building in Bissau where he had spent 94 days.
A group of soldiers went to the UN office and walked out with Na Tchuto, who had been taking refuge there after being suspected of leading a failed 2008 coup.
Ban Ki-moon, the UN secretary-general, urged "the political leadership of Guinea-Bissau to resolve differences by peaceful means and to maintain constitutional order and ensure respect for the rule of law", on Thursday.
Jean Ping, the African Union commission chairman, said in a statement that he was following the events "with great concern".
"In the face of developments which show the volatile nature of the situation in the country and reveal the urgent need for reform of the defence and security sector, the commission chairman calls on all Guinea-Bissau armed forces to respect republican order," the statement said.
Spain, the holder of the rotating European Union presidency, on Thursday called for a swift re-establishment of "legitimate order".
Despite the turmoil and international concern, Sanha said on Thursday that "there is no problem".
"There was a situation of confusion," Sanha said in a statement broadcast on Portugal's Antena 1.
"There was a confusion between soldiers that reached the government, but the situation is calm.
"We are going to try to work on calming the situation and resolve the problem," he said.
The former Portuguese colony has seen repeated coups since independence in 1974.
A new crisis erupted in March 2009 when Joao Bernardo Vieira, the then president, was murdered by troops, apparently in revenge for the killing, hours earlier, of the armed forces chief.
The country has been overwhelmed by the international drugs trade, becoming a key transit point in cocaine smuggling between South America and Europe.