According to a Government Railway Police (GRP), the girl's aunt, who was travelling with her in an AC compartment of Gondwana Express near Sihora station, found the minor girl missing.
The girl's aunt lodged a complaint with the GRP when the train reached here.
The police official said that the minor was found in a sleeper coach and she was in a state of shock and was not speaking.
The 12-year-old girl was rushed to a hospital in an unconscious state after the incident, the GRP said.
Two persons Rahul (19) and Manoj (21), hailing from Ghaziabad (UP), were arrested and booked under section 354 (assault or criminal force to a woman with an intent to outrage her modesty) of IPC.
The duo attempted to outrage the modesty of the girl when she was returning from the toilet in the morning.
After the girl fainted they dumped her where the beddings are kept in the AC compartment, close to the door. Later, they put her on a berth of the sleeper coach, the GRP said.
The medical tests indicate that no attempt was made to rape the girl.