The man was boarding in the Western Australia city of Perth when he slipped and became jammed in the five-centimetre (two-inch) gap between the carriage and the station, operator Transperth said in a statement.
Passengers were initially told to move to the opposite side of the train in the hope their weight would shift it away from his leg, a passenger who gave his name as Nic told The West Australian newspaper.
But when that failed, staff told commuters to get off the train and about 50 of them lined up in a row along the platform to tilt the carriage away from the man so he could be lifted out.
"It is the first time we've seen something like this happen," Transperth spokeswoman Claire Krol told AFP.
"We were really fortunate that the staff were there straight away... and all of the passengers not only listened to the instructions from staff, but pitched in and helped.
"This is a real case of passengers of working together... and people power are the perfect words to describe it."
Transperth said the man was treated by paramedics but was able to catch a later train.
"The end result here is: really lucky for the man involved, but really nice as well to see that everyone came together as a community," Krol added.