Saddam Hussein has been convicted of crimes against humanity and sentenced to death by hanging.
The former Iraqi leader was convicted over the killing of 148 people in the mainly Shia town of Dujail following an assassination attempt on him in 1982.
His half-brother Barzan al-Tikriti and Iraq's former chief judge Awad Hamed al-Bandar were also sentenced to death.
Former Vice-President Taha Yassin Ramadan got life in jail and three others received 15-year prison terms.
Another co-defendant, Baath party official Mohammed Azawi Ali, was acquitted.
Saddam Hussein and his co-defendants will be given the right to appeal, but that is expected to take only a few weeks and to end in failure for the defendants.
Iraqi Prime Minister Nouri Maliki hailed the conviction in a televised address, saying that the sentence was "not a sentence on one man, but a sentence against all the dark period of his rule".
"Maybe this will help alleviate the pain of the widows and the orphans, and those who have been ordered to bury their loved ones in secrecy, and those who have been forced to suppress their feelings and suffering, and those who have paid at the hands of torturers," Mr Maliki said.
US President George W Bush welcomed the verdict as a "milestone" in the efforts of the Iraqi people "to replace the rule of a tyrant with the rule of law".
But the European Union urged Iraq not to carry out the death sentence.
When called to court, Saddam Hussein, dressed in his usual dark suit and white shirt and carrying a Koran, walked to his seat and sat down.
Judge Rauf Abdel Rahman ordered him to stand while he read out the verdict, but the former president refused to do so and had to be moved from his seat by court attendants.
As the judge began reading the death sentence Saddam Hussein shouted out "Allahu Akbar!" (God is Great) and "Long live Iraq! Long live the Iraqi people! Down with the traitors!"
The former leader looked shocked and furious as the sentence was passed, and continued to shout, denouncing the court, the judge and the US-led occupation force in Iraq.
But the BBC's world affairs editor John Simpson said that after his tirade, which was clearly deliberate, Saddam Hussein seemed to have a small smile of triumph on his face as he was led away from the courtroom.
"It was as if he was thinking 'I've come here and done what I intended to do,'" our correspondent said.
Shortly after the verdict there were jubilant scenes in the Shia district of Sadr City, and in the holy city of Najaf.
The Baghdad celebrations came in defiance of a 12-hour curfew on the city, amid fears of violence from Saddam Hussein's Sunni Arab supporters.
Saddam Hussein, former Iraqi president: found guilty and sentenced to death
Barzan Ibrahim al-Tikriti, Saddam Hussein's half-brother: found guilty and sentenced to death
Awad Hamed al-Bandar, Chief Judge of Revolutionary Court: found guilty and sentenced to death
Taha Yasin Ramadan, former Iraqi vice-president: found guilty and sentenced to life in jail
Abdullah Kadhem Ruaid Senior Baath official: found guilty and sentenced to 15 years in jail
Abdullah Rawed Mizher, Senior Baath official: found guilty and sentenced to 15 years in jail
Ali Daeem Ali, Senior Baath official: found guilty and sentenced to 15 years in jail
Mohammed Azawi Ali, Baath official: acquitted
Three nearby provinces are also under curfew, including Salahuddin, which contains Saddam Hussein's hometown of Tikrit.
Thousands also defied the measure in Tikrit - to voice support for Saddam Hussein.
Almost three years since his capture, soaring sectarian violence has brought Iraq to the brink of civil war.
Few Iraqis think the trial verdict will ease conflict, the BBC's Andrew North in Baghdad says.
Even those who want to see their former leader dead do not believe his execution will make things better, our correspondent says.
Many critics have dismissed the trial as a form of victors' justice, given the close attention the US has paid to it.
Before the sentencing session began, former US Attorney General Ramsey Clark was ejected from the courtroom after handing the judge a note in which he called the trial a "travesty".
Saddam Hussein's defence team have also accused the government of interfering in the proceedings - a complaint backed by US group Human Rights Watch.
The process was marked by frequent interruptions by defendants and their lawyers and problems with security.
The first judge assigned to preside over the case, Rizgar Amin, resigned after complaining of government interference and three defence lawyers were assassinated.
And the former leader's lawyers have attacked the timing of the planned verdict, which comes days before the US votes in mid-term elections.
Mr Bush's Republican Party is at risk of losing control of Congress, in part because of voter dissatisfaction over its handling of the Iraq conflict.