Seven of the 12 men convicted for the blasts have been given life sentences.
Seven blasts ripped through trains in the evening rush hour on 11 July 2006, killing 189 people and injuring more than 800.
The attack was blamed on Islamic militants backed by Pakistan, an allegation the country has denied.
A defence lawyer told reporters outside the court that the accused were "innocent" men who had been "framed" and said they would challenge Wednesday's order in the high court.
The 12 men were convicted of murder, conspiracy and waging war against the country earlier this month.
Mumbai's suburban train system is one of the busiest in the world, carrying more than eight million commuters a day.
The bombs were packed into seven pressure cookers and put in bags, and the co-ordinated explosions were detonated within 15 minutes of each other.
The blasts took place in the areas of Matunga, Khar, Mahim, Jogeshwari, Borivali and Mira Road, with most on moving trains and two at stations.
The bombs appeared to have targeted first-class compartments, as commuters were returning home from the city's financial district.
More than 200 witnesses were examined during the eight-year-long trial, which concluded in August last year.
Prosecutors say the attack was planned by Pakistan's intelligence agency ISI, and carried out by operatives of Pakistan-based militant group Lashkar-e-Taiba with help from the Students' Islamic Movement of India, a banned Indian group.
Pakistan had rejected the allegations and said India had given no evidence of Pakistani involvement in the attacks.