CAIRO  Tens of thousands of people demanding an end to the nearly 30-year rule of President Hosni Mubarak filled the streets of several Egyptian cities on Tuesday, in an unusually large and sometimes violent burst of civil unrest that appeared to threaten the stability of one of the United States’ closest Arab allies.

The protests, at least partly inspired by the toppling of the authoritarian government in Tunisia, began small but grew all day, with protesters occupying one of Cairo’s central squares. Security forces, which normally prevent major public displays of dissent, initially struggled to suppress the demonstrations, allowing them to swell.

But early Wednesday morning, firing rubber bullets, tear gas and concussion grenades, the police finally drove groups of demonstrators from the square, as the sit-in was transformed into a spreading battle involving thousands of people and little restraint. Plainclothes officers beat several demonstrators, and protesters flipped over a police car and set it on fire.

Protests also flared in Alexandria, Suez, Mansura and Beni Suef. There were reports of three deaths and many injuries around the country.