Video shows a shirtless man forcing his way into what he mistakenly thought was his friend’s house in Maryland — ending with him being shot dead by the terrified homeowner.

Gerardo “Gary” Espinoza, 46, was captured on doorbell-camera footage initially smiling as he knocked on the front door of a home in suburban Baltimore, just moments before his death.

The footage from the July tragedy was released Tuesday by prosecutors who also announced the homeowner, Charles Dorsey, 56, would not be charged.

“It is clear there was no crime that occurred, although there was a terrible loss of life,” Howard County State’s Attorney Rich Gibson insisted, according to the Baltimore Sun.

Dorsey’s home in Woodbine was close to where Espinoza had been staying.

Having given his name, the video shows the inebriated victim spending 13 minutes growing increasingly enraged, with prosecutors believing he thought he’d been locked out of the home as a prank.

At points, he complies with Dorsey’s requests to leave, only to return even more irate and cursing aggressively.

It ends with Espinoza spewing expletives and rattling the door, eventually forcing it open — the clip cutting before he’s struck while inside the home by a single bullet that pierced his lung.

Gibson expressed “deep sorrow” to Espinoza’s family for the “series of unfortunate coincidences that all came together to end in a horrific result.”

“My honest belief is that Mr. Espinoza thought he was being pranked and the prank had gone on too far,” he said, according to the report.

Dorsey, a legal gun owner, had repeatedly tried to get the stranger to leave, and his wife, Barbara Dorsey, had spent 8 minutes on the phone with a dispatcher while waiting for police to respond, the Sun said.

“Espinoza’s behavior seemed to indicate a desire to harm the people in the house,” Gibson said, according to the paper.

“There was no way for the Dorsey family to know that he did not intend to carry out the threats he was making.”

Espinoza’s toxicology report showed significant amounts of alcohol in his system, perhaps explaining his confusion, the paper noted.

Rebecca Allen, Espinoza’s sister, told the Sun she was “dumbfounded” by the decision.

Gibson met with the family for two hours Tuesday to explain his decision before the announcement, the paper said.

“I think it’s reasonable that they not be thrilled with the outcome in the terms of our decision in this matter. But I’d like to believe that they understand why we reached the conclusion that we reached,” he said, according to the paper.