BENGHAZI, Libya — In a sudden shift after nearly two months of heavy siege, government forces withdrew from the western city of Misurata on Saturday.

By afternoon, forces loyal to Col. Muammar el-Qaddafi had abandoned all but two buildings, where they were surrounded and under pressure to surrender, rebel spokesmen and independent observers said.

But there was little celebration in Misurata as government forces on the city’s outskirts continued to launch barrages of artillery into the heart of the city, killing 24 people on Saturday alone, local doctors said.

The departure came so quickly that even rebel leaders puzzled over whether the withdrawal was a true military victory, a subterfuge by pro-Qaddafi forces who might return in plain clothes, or a strategic redeployment to new fronts in the mountains along the western border with Tunisia.