An Egyptian court has sentenced ex-President Hosni Mubarak to life in prison for complicity in the killing of protesters during last year's uprising.

The 84-year-old is the first former leader to be tried in person since the start of the Arab Spring in early 2011.

But Mubarak suffered a "health crisis" as he was being transferred to prison, Egyptian state TV reported.

Former Interior Minister Habib al-Adly also got a life sentence, but the acquittal of four aides sparked fury.

Mubarak and his two sons were also acquitted on separate charges of corruption.

Shouting and scuffles erupted in court after the verdict was read out.

Outside the building, Mubarak's sentencing was initially greeted by celebrations from relatives of those killed, according to the BBC's Yolande Knell.

Firecrackers were set off. Soha Saeed, the wife of one of the victims, shouted: "I'm so happy. I'm so happy."

But the joy soon turned into angry shouts as the crowd learned that the four senior security officials had been acquitted.

Protesters clashed with riot police. Many headed for Cairo's Tahrir Square, which was a leading focus in the protests that toppled Mr Mubarak. The verdict also sparked angry demonstrations in Suez.

As Mubarak was being transferred from the courthouse to the hospital of Tora prison, near Cairo, state television reported that the former president suffered a "health crisis".

The BBC's Jon Leyne in Cairo says it is difficult to interpret the nature of this particular incident, but adds that Mubarak has had regular health lapses in the past.

Since his trial began last August, he has been held in the International Medical Centre outside the capital, as his lawyer said he was in poor health. Tora prison is where a number of figures from the former government are serving jail sentences for corruption.