A New York City man who allegedly stole from a CVS store was thwarted – not by a law enforcement officer – but by his own heart.

Steven Davis, 49, is accused of stealing 50 pounds of Ensure, a nutritional drink, from a CVS on Manhattan's Upper East Side on Sept. 27. He allegedly swung at a few employees before fleeing the convenience store.

FLORIDA WOMAN LEADS POLICE ON HOURS-LONG CHASE THROUGH BIG LOTS CEILING AFTER ALLEGEDLY TRYING TO SHOPLIFT

Davis was chased by police officers, and the cops eventually found him nearly lifeless on the ground next to a suitcase containing the allegedly stolen items. NYPD Sgt. James Gebhard told the Daily News he thought Davis had been hit by a car.

“His front teeth were knocked out. It was like someone turned off the switch. He must have fallen face first," Gebhard said.

The sergeant administered CPR on Davis – who had suffered an apparent heart attack – and revived him twice before paramedics arrived on scene, WPIX reported.

Despite the man's medical situation, the sergeant said he "went from life-saving to police work pretty quickly" as he tried to successfully ID Davis as the alleged thief.

Davis was hospitalized and released three days later. When he was fingerprinted at a police precinct after being charged with petit larceny, harassment and attempted assault, he ran into Gebhard, the cop said.

CLICK TO VISIT THE ALL-NEW FOXBUSINESS.COM

"He shook my hand and thanked me," Gebhard told the News. "It could have gone one of two ways: he'd be upset with me that I arrested him or he'd be really happy with me that I rescued him."

The 49-year-old man was released on bail and says he's giving up crime. His neighbor, however, claimed Davis says that after each time he's been caught.