(Reuters) - Phoenix firefighters freed a 23-year-old man from a chimney early on Sunday using a drill and sledgehammer after he was locked out of the home by friends playing a prank at a July 4 party, authorities said.

Phoenix Fire Department video shows a crew in helmets drilling into a wall during an operation that department spokesman Aaron Ernsberger said involved about 30 firefighters. Some helped lay air hoses and power cords, while others talked to the trapped man to keep him calm.

“I know, bro’. It can’t be fun,” one firefighter tells the man, before knocking away the last bricks and hauling him out by his legs, shirtless and covered in soot.

The man, who was not identified, was in a stable condition after being taken to a local hospital, Ernsberger said. The incident unfolded in the early hours after a July 4 bash.

“They locked him out, I guess to play a joke on him,” Ernsberger said. “But in his mind he thought he could regain access to the house through the chimney, which turned out to be a really bad idea ... He’s very lucky.”