BBC
The Supreme Council of the Armed Forces (Scaf) said it regretted "the deaths of martyrs from among Egypt's loyal sons".
The violence, which began on Saturday, is the worst since President Hosni Mubarak was ousted in February.
Scaf also said elections would start as scheduled on Monday. There had been speculation that they might be delayed.
In an announcement on Thursday, council member Maj Gen Mukhtar al-Mouallah said the parliamentary elections would be held on schedule. A presidential poll is to take place by June next year.
He said those responsible for deaths and injuries would be held to account, and that protesters arrested since Saturday would be released immediately.
Compensation would be paid to the families of the dead, Gen Mouallah added.
One of them, Maj Gen Muhammad al-Assar, extended "the regret and apology of the entire armed forces on the tragedy that occurred".
He added: "Our hearts bled for what happened. We hope that this crisis will end and, God willing, it will not be repeated again."
The generals urged Egyptians not to compare them to the former regime of Mr Mubarak, insisting they were not seeking to cling to power.
The BBC's Jeremy Bowen in Cairo says public opinion is divided on the forthcoming parliamentary elections.
Some Egyptians want them to go ahead unhindered, while others believe the military must be swept from power first.
The main opposition group, the Muslim Brotherhood, is not supporting the protests and expects to do well in the elections.
Witnesses said that two groups were chanting against other in Tahrir Square on Thursday - one saying "Muslim Brotherhood, we don't want you in the square" and the other responding with a call for unity.
Street battles continued late into Wednesday night. They were heaviest around the fortified interior ministry off Tahrir Square in Cairo.
Workmen in central Cairo have been cleaning up the debris.
One young woman in the square, Safaa Ali, told the BBC: "I'm here because our sisters and brothers have been arrested and killed over there [the interior ministry]."
She said she disagreed with holding elections next week, adding: "We don't trust the army any more. We don't trust them to be the ones supervising the election."
A doctor who only gave his name as Hassan, said he wanted elections to go ahead.
"This election is really crucial," he told the BBC. "We need to move forward. We can't just keep running in circles. What's happening here is not in the best interest of Egypt. I don't know why this is happening."
Protests in Alexandria have been on a smaller scale, but one demonstrator said there was continuing unrest early on Thursday outside the security headquarters.
Egypt's health ministry revised the death toll from 35 to 38 on Thursday, the official Mena news agency reported.
Of the deaths, 33 were in Cairo, two in Alexandria, two in Ismailiya and one in Marsa Matruh, a ministry spokesman said.
The number of people injured since Saturday was 3,256, he added.
Tear gas anger
Correspondents say some protesters have turned their anger towards the US after tear gas canisters were found stamped "Made in USA".
Many protesters complain the type of tear gas is far more potent than that used in February's demonstrations.
A US State Department spokesperson told the BBC they were "closely following these reports, but we cannot confirm what is being used".
On Wednesday, UN Commissioner for Human Rights Navi Pillay condemned the "clearly excessive use of force" by Egypt's security forces and called for an independent inquiry into the deaths.
The protests have continued despite an attempt by Field Marshal Tantawi to defuse the situation by promising presidential elections by June - six months sooner than planned.
He also accepted the resignation of the civilian cabinet appointed by the military. But in his address on Tuesday, Field Marshal Tantawi offered no apologies for the violence.
Meanwhile ratings agency Standard & Poor's cut Egypt's sovereign credit rating to B+, with a negative outlook. S&P said the cut reflected Egypt's "weak political and economic profile".
Egypt's ruling military has apologised for the deaths of about 38 protesters in clashes with police, as protests continue in Cairo and other cities.
The violence, which began on Saturday, is the worst since President Hosni Mubarak was ousted in February.
Scaf also said elections would start as scheduled on Monday. There had been speculation that they might be delayed.
In an announcement on Thursday, council member Maj Gen Mukhtar al-Mouallah said the parliamentary elections would be held on schedule. A presidential poll is to take place by June next year.
He said those responsible for deaths and injuries would be held to account, and that protesters arrested since Saturday would be released immediately.
Compensation would be paid to the families of the dead, Gen Mouallah added.
Continue reading the main story
For the first time, they offered an apology from the entire armed forces. They also appealed to Egyptians not to compare them with the former regime of Hosni Mubarak - something that is increasingly happening.
"We are completely different," said one of the generals. "We do not aspire to power and we do not want to continue in power."
Overnight, a ceasefire halted violence for a while on the edge of Tahrir Square. But there are thousands of protesters still there and little sign this latest apology will pacify them.
Analysis
The generals' tone was completely different from the fairly confrontational address by the head of the ruling military council, Field Marshal Tantawi, on Tuesday.For the first time, they offered an apology from the entire armed forces. They also appealed to Egyptians not to compare them with the former regime of Hosni Mubarak - something that is increasingly happening.
"We are completely different," said one of the generals. "We do not aspire to power and we do not want to continue in power."
Overnight, a ceasefire halted violence for a while on the edge of Tahrir Square. But there are thousands of protesters still there and little sign this latest apology will pacify them.
Late on Wednesday, two members of the council appeared on state TV to offer "condolences to the entire Egyptian people".
He added: "Our hearts bled for what happened. We hope that this crisis will end and, God willing, it will not be repeated again."
The generals urged Egyptians not to compare them to the former regime of Mr Mubarak, insisting they were not seeking to cling to power.
The BBC's Jeremy Bowen in Cairo says public opinion is divided on the forthcoming parliamentary elections.
Some Egyptians want them to go ahead unhindered, while others believe the military must be swept from power first.
The main opposition group, the Muslim Brotherhood, is not supporting the protests and expects to do well in the elections.
Witnesses said that two groups were chanting against other in Tahrir Square on Thursday - one saying "Muslim Brotherhood, we don't want you in the square" and the other responding with a call for unity.
Street battles continued late into Wednesday night. They were heaviest around the fortified interior ministry off Tahrir Square in Cairo.
Continue reading the main story
“Start Quote
Hassan, a doctor in Tahrir SquareThis election is really crucial. We need to move forward. We can't just keep running in circles.”
The clashes were followed by a truce, which appears to be holding. But the protesters have vowed to continue occupying the square until the country's military rulers stand down.
One young woman in the square, Safaa Ali, told the BBC: "I'm here because our sisters and brothers have been arrested and killed over there [the interior ministry]."
She said she disagreed with holding elections next week, adding: "We don't trust the army any more. We don't trust them to be the ones supervising the election."
A doctor who only gave his name as Hassan, said he wanted elections to go ahead.
"This election is really crucial," he told the BBC. "We need to move forward. We can't just keep running in circles. What's happening here is not in the best interest of Egypt. I don't know why this is happening."
Protests in Alexandria have been on a smaller scale, but one demonstrator said there was continuing unrest early on Thursday outside the security headquarters.
Egypt's health ministry revised the death toll from 35 to 38 on Thursday, the official Mena news agency reported.
Of the deaths, 33 were in Cairo, two in Alexandria, two in Ismailiya and one in Marsa Matruh, a ministry spokesman said.
The number of people injured since Saturday was 3,256, he added.
Tear gas anger
Correspondents say some protesters have turned their anger towards the US after tear gas canisters were found stamped "Made in USA".
A US State Department spokesperson told the BBC they were "closely following these reports, but we cannot confirm what is being used".
On Wednesday, UN Commissioner for Human Rights Navi Pillay condemned the "clearly excessive use of force" by Egypt's security forces and called for an independent inquiry into the deaths.
The protests have continued despite an attempt by Field Marshal Tantawi to defuse the situation by promising presidential elections by June - six months sooner than planned.
He also accepted the resignation of the civilian cabinet appointed by the military. But in his address on Tuesday, Field Marshal Tantawi offered no apologies for the violence.
Meanwhile ratings agency Standard & Poor's cut Egypt's sovereign credit rating to B+, with a negative outlook. S&P said the cut reflected Egypt's "weak political and economic profile".