A Manhattan man was sprung from an upstate prison Thursday after serving 15 years — only to be shot 15 minutes later by a thug he snitched on, law enforcement sources told The Post.

The 33-year-old man was released from Otisville State Prison at 9:45 a.m. with a train ticket for a trip to a halfway house in Manhattan.

But when he got outside, someone in a white Hyundai offered him a ride — an offer he quickly accepted.

After about two miles, the car pulled over and a second person hopped out of the trunk, pulled out a gun and fired two shots at the newly freed man, police sources said.

The victim stumbled to the Metro-North station in Otisville, where workers called for help, sources said.

He was taken to West­chester Medical Center and is in stable condition.

The victim — who served time for criminal sale of a controlled substance, weapons and assault — identified the shooter.

The guman had a beef with the victim for snitching on him, sources said.

Cops tracked the two suspects — Jerome A. Mack and Edgar Wilson, both 35 — to the Upper East Side and arrested them Thursday evening.