MANHATTAN — About 500 people were stranded for nearly 2 hours on board an LIRR train when it stalled because of a third rail problem on Amtrak tracks just before the East River tunnel Thursday morning, officials said.

The train, which had left Port Washington about 5:09 a.m., was approaching the tunnel about 5:50 a.m. when the train stalled because of an electrical problem on the tracks, according to MTA spokesman Aaron Donovan.

The passengers were given water and a rescue train pulled them to Hunterspoint Avenue about 7:40 a.m., but not before delays and cancelations rippled through the commuter rail network, officials said.

Every LIRR train heading into Penn Station was delayed up to 15 minutes and many were either rerouted or canceled, officials said.

.@MTA .@LIRR Due to track condition, expect various delays & cancellations on LIRR trains into Penn Station. Info: https://t.co/ENIxXVnNZ4. — NYCEM - Notify NYC (@NotifyNYC) June 29, 2017

Amtrak, which operates the track where the train stalled, dispatched crews to the scene, the MTA said about 8:15 a.m.

A spokesman said they are investigating the problem.

Some trains are being diverted to Hunterspoint Avenue and Atlantic Terminal, the MTA said.

The subway system is cross honoring fares, officials said.

Check the MTA's website for updates.