Military police attempted to break up a protesters camp in central Cairo on Friday, setting off violent clashes that left at least eight people dead and almost 300 injured and overshadowed the tallying of votes cast in the second phase of parliamentary elections.

The violence outside the cabinet building marked the worst unrest in the capital since a six-day-long crackdown on demonstrators demanding an end to military rule last month left at least 42 people dead. Observers worried that the latest move against protesters could undercut voting in the final round of lower house elections — the first poll since President Hosni Mubarak’s ouster in February.

At least two members of a newly formed advisory council, expected to be an influential sounding board for the military rulers during the writing of a constitution, resigned in protest against the crackdown. Ahmed Khairy, a member of the Free Egyptians party, apologized for joining the military-appointed body.

“I announce my resignation from the advisory council and I apologize to all those who blamed me for joining,” he wrote on Twitter. “You were right.”

The Health Ministry said that at least eight people were killed in the clashes, which began before dawn Friday and were still raging Saturday morning. Protesters were throwing firebombs, igniting blazes, and witnesses reported live ammunition being fired into crowds. A doctor at a field hospital said at least seven people were injured by gunfire.

Early Saturday morning, flames erupted on Qasr el-Aini Street, which leads from Tahrir Square to the cabinet building, and in a government building. Hundreds of protesters threw stones at security forces that had sealed off the streets around the parliament building. According to the Associated Press, soldiers on rooftops pelted the crowds below with stones, forcing many of the protesters to pick up helmets, satellite dishes or sheets of metal to protect themselves.

“This is a threat to Egypt’s safety at this critical stage of the peaceful transition of power and elections,” said advisory council member Nadia Mustafa, who suspended her participation. “We are not willing to hear any more stories about a third party and infiltrator who is trying to cause strife between the people and the military” — a reference to authorities’ assertions that foreign conspirators are behind the unrest.

The military council said in a statement late Friday that soldiers were acting in self-defense against protesters who shot at them and lobbed rocks and Molotov cocktails. It did not explain the deaths of protesters or the injuries attributed to gunfire and blamed the media for stoking the unrest.

Later, the advisory council said at a news conference that it had urged the military council to end the violence against protesters, open an investigation, apologize to the injured, compensate bereaved families and release all those detained. It said all its members would resign if its recommendations were not met.

The initial popularity of the ruling generals has declined in the past 11 months, with activists accusing them of failing to reform government institutions and slowing the transition to civilian rule. The violence comes a day after judges said they were beaten by military police outside polling stations they were to supervise Thursday and some threatened to boycott the third round of voting, according to local news reports.

Early second-round results released in al-Ahram, a state newspaper, and by the Muslim Brotherhood indicated that the Brotherhood’s Freedom and Justice Party was reinforcing its lead after winning about 47 percent of seats in the first round of voting. The ultraconservative Nour Party also appeared to have polled strongly, while the most successful liberal coalition, the Egyptian Bloc, had slipped.

According to the state news agency MENA, the violence erupted Friday after some protesters mobbed the cabinet building.

But witnesses said the clashes started after military police seized a protester outside the building and beat him severely. Images posted online showed a man, identified as Aboudi Ibrahim, being carried away by fellow protesters, his face bruised and his eyes swollen shut. A doctor at Qasr el-Aini hospital said Ibrahim died while being treated, which would bring the death toll to three.

Military police tried to disperse the crowd, burning tents where protesters had been encamped for three weeks in a bid to stop the caretaker government from convening, witnesses said. Soldiers atop nearby government buildings threw rocks and glass at the crowd below, according to witnesses and video footage.

By late Friday morning, military police in riot gear had rushed Qasr el-Aini Street, beating protesters with truncheons. A young woman, Ghada Kamal, 28, tried to stop them from hitting a fellow protester and was beaten to the ground by several military police officers, who then detained her. At least six women were among the scores of protesters who were detained and later released, many bleeding and reeling from what they said were shocks from cattle prods.

Also among the dead was Sheik Emad Effat, a cleric from al-Azhar, Egypt’s preeminent religious institution, MENA reported.

Noor Ayman Nour, an activist and son of former presidential candidate Ayman Nour, limped through the rock-strewn street after being released Friday. A welt bled on his forehead.

“The military police were running after us and a girl tripped and I went to help her and they started to beat me,” he said.

Outside the cabinet building, families begged the military through the locked gates to release their relatives.

“The people want the execution of the field marshal,” protesters chanted, referring to Egypt’s top general, Mohammed Hussein Tantawi.

Nearby, young men siphoned gas from cars to make small firebombs.

Mohamed ElBaradei, a favored presidential candidate among youthful protesters, wrote on his Facebook page, “Even if the sit-in was not legal, should it be dispersed with such brutality and barbarity?”

Special correspondent Ingy Hassieb contributed to this report.