The rail travellers had been delayed for seven hours on their journey from London.
After finally arriving at Bath station at 0400 GMT, the weary travellers discovered the station doors were locked and all staff had left.
Some of the passengers formed a battering ram to break down a door while others walked across the tracks.
The journey by First Great Western inter-city express from London's Paddington station to Bath Spa - 110 miles away - should have taken one and three-quarter hours.
Instead, the 2030 GMT and 2130 services on Sunday night were delayed because of a derailed train.
Passengers eventually left the west London terminus at 0110 GMT on Monday morning - but were again delayed at Reading.
Passenger Jim Crawley said: "We arrived at Bath to find when we got to the bottom of the stairs that every single door was locked and effectively we were locked in.
"We went back up to the platform and I could see people were climbing over a fence with points on the railings so they could have seriously injured themselves.
"Some people even went across the rails to the other platform.
'Extra services'
"When we got back downstairs people were milling around and someone just decided, 'blow this' and kicked the door open and we all got out, so we did escape."
A spokesman for First Great Western said: "We have apologised for a lack of communication between our staff.
"There were exceptional circumstances as a result of the derailment.
"There were a number of passengers who were stranded at Paddington so we laid on extra services in the early hours.
"A train went through Bath at 2am and our staff there mistakenly thought that was the last service."