The sentence was awarded within 52 days of the incident.
The judge held Golu alias Bihari Chadhar (25), Amar alias Ghuntu (24), Rajesh Chetram alias Raju (26) and Ramesh Mehra alias Raju (45) guilty of raping the woman near the railway station when she was returning home after attending a coaching class on October 31.
"They will remain behind bars for the rest of their lives," the court said.
The four men were convicted under IPC sections pertaining to attempt to murder, gangrape, voluntarily causing hurt, wrongful confinement, wrongful restraint and other relevant sections, additional public prosecutor Reena Verma told reporters.
The court also imposed a fine of Rs 3,000 and Rs 5,000 on each of the four men, she said.
A 200-page chargesheet in the case was filed 16 days after the woman was allegedly raped.
The survivor, daughter of a police couple, had to make rounds of different police stations to get her complaint registered as the police initially refused to lodge an FIR, citing a jurisdiction issue. After public outrage over the delay in the registration of the FIR, five police personnel were suspended, while three others, including two IPS officers, were transferred.
A special investigation team was set up by the Madhya Pradesh police to probe the crime. The SIT completed its probe in 15 days.