WASHINGTON — President Obama on Friday ordered Col. Muammar el-Qaddafi to carry out an immediate cease-fire, withdraw his forces from rebel-held cities and stop all attacks on Libyan civilians or face military action from the United States and its allies in Europe and the Arab world.

“Let me be clear, these terms are not negotiable,” Mr. Obama said from the East Room of the White House. Those terms, particularly lifting the siege of opposition-held territories, would give the rebels a reprieve, if not a military advantage.

Libya had pledged a cease-fire hours before. But reports from rebel-held territory indicated that the attacks by Qaddafi militias continued unabated in the east and west.

Government forces continued to advance on Benghazi, the rebel’s capital in the east, and people fleeing nearby Ajdabiya said troops were shelling and conducting assaults in the afternoon. The western city of Misurata was under siege, its electricity and water cut by the government, and doctors reported that at least 25 people were killed, including 16 unarmed civilians. In Tripoli, the repression of peaceful protests continued, and gunfire was heard late in the evening.