The Norfolk Southern train derailed late Tuesday night, according to a statement from Gov. Andrew Cuomo.
Sixteen of its 34 cars derailed, and two of those were leaking ethanol, Norfolk Southern said.
The leaks are under control, the company said. The punctures have been patched, and any remaining drips of ethanol are being captured in a bucket.
Chautauqua County Sheriff Joe Gerace said the cars -- holding more than 30,000 gallons of ethanol -- were leaking about a gallon a minute at one point.
No injuries or fires were reported, but emergency responders were on the scene to contain the spill.
"This could have been catastrophic," Gerace said.
The sheriff added that about 30 people were in shelters after 45 homes were evacuated. Ripley is more than 400 miles northwest of New York City.
Crews were clearing the tracks Wednesday, according to the sheriff.
Cuomo said the main CSX line was open at reduced speeds.
The cause of the derailment is under investigation, Norfolk Southern spokesman David Pidgeon said.
He added that crews were working to transfer the ethanol off of the affected train cars and remove it from the scene.
"We are also testing and removing impacted soil in the area," Pidgeon said.
Gerace said crews were also trying to prevent the ethanol from leaking into the sewage system and a nearby lake.
Ripley schools were closed Wednesday and residents near the derailment were asked to shelter in place, CNN affiliate WKBW-TV reported.