The protest in the central square was the largest yet in the popular uprising that began a month ago - and the harsh government response marked a new level of brutality from the security forces of President Ali Abdullah Saleh, a key - if uneasy - ally in the U.S. campaign against al-Qaida who has ruled Yemen for 30 years.
Dozens of enraged protesters stormed several buildings that were the source of the gunfire, detaining 10 people including paid thugs who they said would be handed over to judicial authorities.
Demonstrators have camped out in squares across Yemen for over a month to demand that Saleh leave office. Security forces and pro-government thugs have used live fire, rubber bullets, tear gas, sticks, knives and rocks to suppress them. The protesters say they won't go until Saleh does.
"They want to scare and terrorize us. They want to drag us into a cycle of violence - to make the revolution meaningless," said Jamal Anaam, a 40-year-old activist camping out in the square that the protesters call "Taghyir Square" - Arabic for Change.
"They want to repeat the Libyan experiment, but we refuse to be dragged into violence no matter what the price," he said.
Before the shooting Friday in Sanaa, a military helicopter flew low over the square as protesters arrived from prayers. Gunfire soon erupted from rooftops and houses above the demonstrators, where eyewitnesses said beige-clad elite forces and plainclothes security officials took aim.
Other police used burning tires and gasoline to make a wall of fire that blocked demonstrators from fleeing down a main road leading to sensitive locations, including the president's residence.
Panic and chaos swept the square, where dozens of dead and wounded sprawled on the ground. Witnesses said the snipers aimed at heads, chests and necks. Protesters carried their friends, scarves pressed over bleeding wounds.
"It is a massacre," said Mohammad al-Sabri, an opposition spokesman. "This is part of a criminal plan to kill off the protesters, and the president and his relatives are responsible for the bloodshed in Yemen today."
Saleh announced a press conference later Friday. Opposition groups also planned an emergency meeting to discuss their next steps.
Before the protests, Yemeni elite forces fortified the president's residence, the interior ministry, the defense ministry and the building housing the ruling party, apparently fearing demonstrators would storm those areas, as they have done elsewhere in uprisings across the Middle East.
Doctors at the makeshift field hospital near the protest camp at Sanaa University confirmed at least 31 dead, three of them children. They spoke on condition of anonymity because they were not authorized to speak to the media.
Medical officials and eyewitnesses say hundreds were wounded in Friday's violence, which marks a dramatic escalation of the crisis that has engulfed Yemen.
The protests are just one of the problems in this extremely poor, tribal country. Saleh's weak central government also faces one of the world's most active al-Qaida branches, a secessionist rebellion in the south and a Shiite uprising in the north.
Karam reported from Cairo.