The number 1618 ICE (Intercity Express) left Berlin Südkreuz at 4:54 am with only 25 passengers on board.
When the conductor passed through the carriages to check passengers' tickets just after the train had left the city limits, a 23-year-old man drew a weapon and began threatening him.
Although he fired several times, no-one was hurt. Other passengers were able to overpower the gunman.
A spokesman for Brandenburg police told The Local that while the passengers' actions were brave, he couldn't recommend people try to intervene in similar cases.
"You always have to decide for yourself in a situation like that whether you feel able to step in," he said.
The train driver called the police and stopped in Nauen so that they could take the man into custody.
Train lines between Berlin and Hamburg were closed for a quarter of an hour until 6 am and several other services were delayed.
Police later said that the weapon used was firing blanks.
Brandenburg detectives are currently investigating the motive of the crime, helped by a letter with demands which the gunman had on him.