CAIRO — The battle had gone on for hours, and the end of the bridge was in sight. Somewhere past the green armored cars and through the smoke was Liberation Square. For miles the protesters had marched peacefully, shouting at balconies for their neighbors to join them.

But water cannons and tear gas halted the march, for a time. Atef Badr, 28, turned to the retreating protesters with tears stirred by the moment, not the gas. “I’m begging you,” he screamed. “All of you in the back, come forward!”

A few tear gas canisters got caught in the wind and drifted away toward the river: an opportunity. The protesters surged forward, chanting, “Overthrow Mubarak!” They gained ground and then lost it, when the dull metal gas canisters started falling again.

So it went all afternoon on the Kasr al-Nil Bridge, as thousands of protesters tried again and again to get past the riot police, who were just as determined to keep them at bay: first with gas and water cannons, and then by beating them with truncheons.

The long struggle for the bridge set the tone for the momentous events throughout the country on Friday. Egyptians slowly shed their fear of President Hosni Mubarak’s police state and confronted its power, a few halting steps at a time.

The protesters came from every social class and included even wealthy Egyptians, who are often dismissed as apolitical, or too comfortable to mobilize. For some of them in the crowd on Friday, the brutality of the security forces was a revelation. “Dogs!” they yelled at the riot police, as they saw bloodied protesters dragged away. “These people are Egyptians!”

The protests started around noon, miles from the bridge, with prayer at a mosque and a sermon praising the young protesters. Anticipating the clashes, a police officer adjusted his riot helmet. A restaurant shuttered its doors.

Everyone seemed nervous. Nasser al-Sherif, 24, looked for his friends, who were late. It was his first protest in Egypt. “I’m just here to say no,” he said. “Once things get rough and violent, I might leave.”

Ibrahim al-Missiri, 36, looked at the crowd, which included two famous actors. “This is the class that never spoke out before,” he said. “I want the right to vote.”

The prayer ended, and the protesters, herded by a ring of riot police officers, started walking away down a side street and then stopped, turning back for their first confrontation of the day.

The police let them pass.

On a broad avenue, hundreds swelled to thousands. Three young men, old school friends, marched among them. Two of them worked at a call center for the Expedia Web site, earning a little more than $400 a month. They had all been intending to leave Egypt. The protests were changing their minds.

“We’ve had enough time stolen,” said Ali Bilal, 23. “We want to take control of the situation.”

Friends pushed a man in a wheelchair. A fruit vendor begged off calls to join the protests, pointing out that he would have to leave his donkey. On a balcony, an elderly woman looked at the crowd and threw her hands in the air. On other balconies, there was applause.

“Peaceful,” the marchers shouted. At the foot of the bridge, the security services were waiting, with other plans.

When the first tear gas canisters landed, Ziad Ali wondered whether the march would go on. “I’m 35; he’s been the president since I was 5,” he said of Mr. Mubarak. “I hope we can make it this time.”

At key moments young men inspired the marchers. A man with a red scarf wrapped around his face stood on a statue near the foot of the bridge, defiantly, as the tear gas clouds swirled around him.

Another man yelled into a bullhorn, telling protesters it was fine to fall back but not to retreat. A third managed to climb on top of one of the four green personnel carriers blocking the bridge, as the riot police fell back. The crowd cheered and advanced, as the first hurdle fell.

Abandoned by their comrades, the officers still in the transport trucks, no longer fearsome, sobbed as the protesters occupied the bridge for the first time. A local police chief was carried off the bridge bleeding from the head, joined by many people wounded by the falling canisters. When the bursts from the tear gas launchers quickened, the protesters retreated, until the young men at the front told them to come back.

The nearby 6 October Bridge filled with people, and the marchers on Kasr al-Nil cheered. The plan was to march to Tahrir, or Liberation, Square, in downtown Cairo, to link up with other groups of protesters. In the distance, a building burned.

“This is the first time I’ve seen collective action,” said Omar Barazi, 44, pondering the future. “I think there will be chaos and losses.”

That moment came quickly. Police officers watched the assault from boats. Hundreds of riot officers stormed the bridge, throwing benches and a police hut into the Nile and beating anyone who did not run. By late afternoon, they had retaken Kasr al-Nil and penned in a group of protesters next to a park.

Officers fired tear gas toward an opera house as the young men ran away, and for the protesters, everything seemed to be lost. Nadine Sherif walked among badly wounded comrades, despondent. “I hope he gets the message,” she said of Mr. Mubarak. “He’s not wanted.”

A few officers lit cigarettes, relaxed and chatted easily with the protesters, thinking they were done.

They were not. Night fell, and the protesters finally took the bridge.