The first three carriages of the 12-car Long Island Rail Road train came off the tracks about half a mile east of New Hyde Park station, New York Gov. Andrew Cuomo said in a statement.
New Hyde Park is about 20 miles east of Manhattan.
The eastbound train derailed after colliding with part of a work train running in the same direction on an adjacent track, Metropolitan Transportation Authority Chairman Tom Prendergast told reporters.
A piece of equipment from the work train ended up "violating the clearance envelope of the other track," he said.
The work train reportedly caught fire after the collision.
"Why was the work train violating the space? That's what we are going to have to find out," Cuomo told reporters.
Among the injured were 26 passengers and seven employees, two of whom were on the work train. Four people were seriously injured, although none have life-threatening injuries, Prendergast said.
Train walls buckled
Cuomo said about 600 passengers were on board the Huntington-bound train at the time. First responders treated people at the scene, while the more seriously injured were taken to a hospital.
Images from inside the train showed walls buckled in from the force of the collision. A block of seats and a table were dislodged, and the floor strewn with debris.
CNN employee Jeff Abrahams, who was a passenger on the train, said people were comforting one another after the derailment. One injured woman was crying, saying she believed both her legs were broken.
Transport authority staff were at the scene and would "work around the clock to determine the cause of this derailment and restore service as quickly as possible," Cuomo said.
Service on the line was suspended in both directions on the Ronkonkoma, Oyster Bay and Port Jefferson branches.
Officials were working to remove the trains from the tracks so that other trains can run Monday.
The derailment comes nine days after a packed New Jersey commuter train crashed into Hoboken Terminal
, killing a woman waiting on the platform and injuring more than 100 others.