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.
Mubarak's sons, Alaa and Gamal, are to remain in detention despite their acquittal because they are to go on trial on charges of stock market manipulation.
'Years of darkness'
In his preamble, Judge Ahmed Refaat insisted the 10-month trial had been a fair one.
He spoke of the Mubarak era as "30 years of darkness" and praised what he called "the sons of the nation who rose up peacefully for freedom and justice".
Announcing the verdicts, the judge then said Mubarak and Adly had failed to stop security forces using deadly force against unarmed demonstrators.
Mubarak, who ruled the country from 1981 to 2011, had faced a possible death sentence over the killing of about 850 protesters.
Egypt's Muslim Brotherhood – the main opposition force under Mubarak's rule – said the defendants must be retried.
"The public prosecutor did not carry out its full duty in gathering adequate evidence to convict the accused for killing protesters," said Yasser Ali, a spokesman for brotherhood.
The prosecution experienced difficulties during the trial. Its first five witnesses recanted initial statements that police commanders had been ordered to use live ammunition against demonstrators.
But presidential candidate and Mubarak's last prime minister, Ahmed Shafiq, said that the verdicts "must be accepted".
The ruling comes as political tensions are rising in Egypt between the two rounds of voting in a presidential election.
Correspondents say many of Egypt's revolutionaries are bitterly disappointed by the choice they now face – between a Muslim Brotherhood candidate, Mohammed Mursi, and Mr Shafiq.
The first leader toppled during the Arab Spring was Zine al-Abidine Ben Ali of Tunisia, who was found guilty in absentia of drugs and gun charges in July.
Libyan leader Muammar Gaddafi was killed by rebels in October. Yemen's Ali Abdullah Saleh received immunity from prosecution after handing over power in November.Post published in: Africa News