A would-be Park Slope purse-snatcher accidentally gave himself the death penalty Saturday night, when he ran onto subway tracks to escape cops — and was electrocuted by the third rail, according to police sources.

The mugger, whose name was not released, had tried to grab a brown, Louis Vuitton purse from a young woman near Fourth Avenue and Ninth Street at around 7:30 p.m., the sources said.

He was spooked — possibly by nearby cops — and ran, without the purse, into the corner subway station, where he dashed onto the tracks.

The man ran north underground along the northbound R Train tracks for ten blocks, almost to the Union Street station, where cops were waiting above ground for him to re-emerge.

Instead, he tripped and fell on the third rail just before the station.

When cops caught up with him, he was dead at the scene, police said.

“I don’t think he knew what he was about to get into,” one detective said, shrugging. “He gambled and he lost.”

Power was shut off at the Union Street station while the man’s body was recovered. The MTA provided shuttlebuses to take stranded travelers to the Atlantic Avenue station.