According to railway police, the girl, residing in Wadala area, used to come to suburban Bandra daily to attend her nursing course classes.
The two accused - Mehakarul Shaikh, 35, Nijamul Mussa Lashker, 22, and their friends - had been passing lewd remarks, besides following her till her house in the night for the past few days, police said.
The girl expressed her ordeal to her friend, who narrated it to an NGO which subsequently notified railway police.
Accordingly, a trap was laid Monday night at the Bandra railway station when Shaikh and Lashker were found brazenly passing vulgar comments at the girl around 9.30 pm.
The railway commuters intervened and began thrashing the two accused before police could nab them, a police official said.
"The two were subsequently arrested by Bandra railway police," he added.
A spate of sexual and mental harassment cases were reported in the city in the past few months, prompting Mumbai Police Commissioner Satyapal Singh to instruct his department to initiate severe action against such offenders.
In August, a young photojournalist was allegedly gang raped by five men at a deserted mill in the heart of the city, which sent shock-waves across the nation.
Voters can exercise 'right to reject' during MP elections
Mumbai gives Narendra Modi a welcome to remember!
FIR likely against Jignesh Shah, former NSEL brass
A 'foolproof' plan to secure Lord Ganesh
Delhi: Domestic help with knife injuries rescued, employer booked