Prosecutor J.M. Panchal says the court also gave 20 other convicts life imprisonment in the case, which triggered one of India's worst outbursts of communal violence in western Gujarat state.
The sentence was announced Tuesday by Judge P.R. Patel.
Patel last week convicted the 31 Muslims of being part of a criminal conspiracy that led to the deaths of 60 people when one of the coaches of the Sabarmati Express train was set on fire in 2002.