As the inferno and thick black smoke raced through the car at about 3:45 a.m., panicked passengers broke the windows and many saved themselves by jumping from the train.
Sixty-seven passengers were in the carriage when the fire broke out about 2 kilometers (1 mile) from the small town of Puttaparthi in Andhra Pradesh state, said railways spokesman C.S. Gupta.
The train was brought to a halt and the burning coach was delinked from the rest of the cars to prevent the fire from spreading, Gupta said.
The fire spread to a second coach, but the blaze was put out before it caused much damage, Gupta said.
Firefighters put out the blaze in the burning coach and retrieved at least 26 bodies, including two children, said a railway official at the site of the fire. More than a dozen people were brought to hospitals with injuries sustained when they jumped from the train, the official said on condition of anonymity because he was not authorized to speak to the media.
Firefighters had to force the doors open and make their way through the smoke-filled coach to reach the dead, the official said.
Many bodies were found near the jammed doors, he said.
Medical teams carried out autopsies to identify the bodies, many of which were charred beyond recognition.
The train was traveling from Bangalore to Nanded in the western state of Maharashtra.
Railways Minister Mallikarjun Kharge said preliminary reports from the site indicated that the fire was caused by an electrical short circuit. An investigation was underway.
Accidents are common on India's railroad network, one of the world's largest, with some 18 million passengers daily. Most collisions and fires are blamed on poor maintenance and human error.