Government Railway Police sources said E Jaya Gopi, the accused, was drunk at the time.
He took the woman to an AC compartment on the pretext of collecting the fare difference, and allegedly made a pass at her.
She shouted for help and other passengers came to her rescue.
The 23-year-old woman had boarded the train in Chennai with a general ticket and had approached the accused for a reserved berth, said Gudur GRP Sub-Inspector K Srinivaschary.
Gopi was taken into custody at Gudur railway station and booked on the charge of outraging the modesty of a woman.
Railway authorities later suspended him from service.