Libyan authorities blocked foreign journalists from leaving their hotel to report on expected protests by opponents of Libyan leader Muammar Gaddafi after Friday prayers.
When journalists including Reuters reporters tried to walk out of the gates of the main media hotel, to the south of Tripoli city centre, security guards blocked their way.
A Libyan government spokesman said journalists were being kept in the Rixos hotel because their presence could trigger violence from what he described as affiliates of al Qaeda.
"These are exceptional circumstances. I know you're going to talk about it and twist it the way you want," said the spokesman Mussa Ibrahim. "We are preparing to pay this price of preventing you guys from reporting to avoid turning Tripoli into Baghdad."
A revolt against Gaddafi's four-decade rule has left the eastern side of the country, and several towns elsewhere, in rebel control with the capital now his principal strong-hold.
Several residents of Tripoli have said they are planning to protest against Gaddafi when they leave their mosques after Friday prayers, and that they anticipate a violent crackdown by armed pro-Gaddafi militias.
Overnight, gunshots could be heard outside the Rixos hotel. Ibrahim said the firing was an attempt by the rebels to disturb stability in central Tripoli.
About 130 journalists are in the hotel after being invited to Libya on an officially-organised media visit. Their movements are monitored by officials.