More than 500 riders on the No. 7 train had to be evacuated Monday morning after an equipment malfunction caused smoke to seep into some cars and left passengers stranded for about two hours.

Riders were stuck below the East River until police and firefighters got 542 passengers on board a rescue train that took them to Grand Central Station from the Vernon Boulevard-Jackson Avenue station in Long Island City.

The train came to a halt in a tunnel between Manhattan and Queens around 8:30 a.m. when a piece of train equipment that is supposed to make contact with the electrified third rail actually ended up on top of the protection board, causing a smoke condition, according to MTA spokesman Adam Lisberg.

“We are trying to figure out how that happened,” he said.

One woman who felt ill was taken to New York Presbyterian Hospital, according to fire and transit officials.

Raul Rojas, a 46-year-old East Elmhurst resident, said he had to wait about 90 minutes until a rescue train came up.

“We thought it was going to be another 10-minute wait,” said Rojas, who recorded video of his fellow stuck passengers.

But the minutes kept piling on, as people in his train car kept calm, he said. Eventually, the rescue train to Grand Central arrived. The 7 train was back in service around 10:30 a.m. with extensive delays along the line.

The No. 7 train has been dogged by overcrowding and service problems, but also a spate of incidents that have left riders stranded. The tracks’ third rail in February iced over, leaving riders sitting on the elevated line for more two hours and causing commuting havoc for the rest of the day. More than 2,000 riders on several trains sitting on the tracks suffered through the wait, until MTA crews could restore power.

“It’s upsetting ... that we’re not riding a more consistently working train system,” Rojas said.

Riders in the meantime griped on social media and snapped photos of the stalled train and the move to the rescue train with the help of fire and police officials.

“After being stuck underground, with no service, in a somewhat smoke filled train for two hours my comrades and I finally made our way to the rescue train,” wrote one 7 train rider on her Instagram.