The incident occurred in the town of Essert-sous-Champvent on the train line connecting Baulmes and Yverdon-les-Bains in the Swiss canton of Vaud near the French border.
"The hostages were all released unharmed," police in the Vaud canton said in a statement on Friday. "The hostage taker was fatally wounded during the intervention."
Police did not provide any details regarding the possible motives of the man, who police said was a 32-year-old Iranian asylum seeker.
Jean-Christophe Sauterel, police spokesperson for the Vaud canton, said there was no indication that the hostage taking was a terrorist incident.
"It's an unprecedented event given the number of victims, 15 hostages, and the intervention of 60 police," Prosecutor General Eric Kaltenrieder told local television.
Hostage situations are rare in Switzerland but have occurred at banks and businesses. In January 2022, employees of a watch making firm were taken hostage and forced to open a vault containing precious metals.