A thief snatched a cellphone from a 13-year-old subway rider and tried to flee on the tracks in Queens on Tuesday — but karma caught up to him when he ran into an oncoming train, police sources and witnesses said.

The 33-year-old crook grabbed the phone and bolted from an M train into a subway tunnel near the Northern Boulevard station in Woodside at around 8 a.m., the sources said.

But the brainless bandit made it only a short distance before spotting a Manhattan-bound F train — packed with rush-hour commuters — barreling toward him, according to police and MTA sources. The train sideswiped the man near the 65th Street subway station, leaving him with cuts and bruises, MTA sources said.

“He was running down there like a trapped rat with trains speeding around him,” said a transit superintendent.

The crook claimed he had been zapped by a third rail, and was bawling like a baby when the superintendent found him, he said.

“I came up on the guy and he was crying, saying he got shocked by the train, saying he got electrocuted. His lip was bleeding. When I saw him, he was on his knees with some blood on his lip, drooling, moaning,” he said.

Morning commuters had to wait more than an hour while firefighters and police tended to him, MTA sources said.

Click here for more from the New York Post.