Dozens of people suffered non-lifethreatening injuries after a freight train car rolled from a side track onto the main line and struck a stationary commuter train Tuesday afternoon.

Lt. John Hutchinson of the Canton Fire Department, said about 150 people were treated at the scene and about 80 were taken to hospitals. None of the injuries were life-threatening, he said. Most were minor.

Joe Pesaturo, spokesman for the Massachusetts Bay Transportation Authority, said about 300 passengers were on the Stoughton-bound train.

Pesaturo said the CSX freight car, loaded with lumber, rolled about two miles from where it had been parked at a lumber yard on the siding. It traveled onto the Stoughton commuter rail branch line, then onto the main line where it struck the passenger train's locomotive near Canton Junction just before 5:30 p.m.

Pesaturo said the engineer, who was among those injured, was alerted by a track signal that something was on the line and was able to stop the commuter train before the crash.

He said authorities are investigating how the freight car came loose.

Scott Farmelant, a spokesman for the Massachusetts Bay Commuter Rail, which operates the service for the MBTA, said the train was Number 917, which left Boston's South Station at about 4:40 p.m.

CSX spokesman Gary Sease said the flat car had been placed at a customer's location earlier in the day. He said the company is cooperating in the investigation.

"Our first concerns are the safety of the passengers and train crew," Sease said.

Passenger Tony Phillips, 42, of Stoughton, told The Boston Globe the train suddenly stopped as it approached Canton Junction and there was a loud bang. "People were screaming 'Oh my God, what happened?'," he said.

Another passenger, Gary Rozenas, 55, of Brockton, told the Boston Herald the crash ignited a small brush fire outside the train. "All the lights went out and people were flying down the aisles and people were on the floor of the car," he said. "The car began filling up with dust and the scary part was part of the woods was burning up outside the doors."

Pesaturo said train service resumed Tuesday evening between Boston, Attleboro and Providence, R.I., on the line, but passengers were being bused between Canton and Stoughton as crews worked to separate the freight car from the locomotive.