A man is being praised for his quick thinking after he rescued a dog whose leash had gotten caught in an elevator.

Johnny Mathis recalled the incident on Twitter, where he shared security footage taken inside his Houston, Texas, apartment building of the rescue.

“Y’all I’m shaking!” Mathis wrote. “I just saved a dog on a leash that didn’t make it onto the elevator with the owner before the door closed! I just happened to turn around as the door closed and it started to lift off the ground I got the leash off in time.”

In another tweet, Mathis continued: “She started screaming as soon as the door shut and was bawling her eyes out when it came back down.”

In the video, which has been viewed more than 16m times, the owner can be seen entering the elevator while the Pomeranian is still a few feet away. After the elevator doors close, Mathis rushes over and struggles to release the dog’s collar from the leash.

In subsequent tweets, Mathis said that he did what he “had to do to help the pup” and that he was “thankful” he was there “at the right time to help”.

According to the 27-year-old, his first instinct was to “break” the leash, but he found he was unable to.

“I tried to break it at first,” he told NBC News. “I tried to lean down on it with all my weight but it wouldn’t snap.”

Dog Photographer of the Year award Show all 29 1 /29 Dog Photographer of the Year award Dog Photographer of the Year award overall-winner-and-1st-oldies-denise-czichocki-c.jpg 1st Place Oldies Overall Winner *** Local Caption *** My mobile number is 0041 784032006 28/5 confirmed her win 29/5 emailed info Denise Czichocki Dog Photographer of the Year award 1st-portrait-anastasia-vetkovskaya-c.jpg 1st Place Portrait *** Local Caption *** 29/5 emailed info Anastasia Vetkovskaya Dog Photographer of the Year award 1st-dogs-at-play-monica-van-der-maden-c.jpg 1st Place Dogs at Play *** Local Caption *** 24/5 confirmed win 29/5 emailed info Monica van der Maden Dog Photographer of the Year award 3rd-portrait-sheena-staples-c.jpg 3rd Place Portrait *** Local Caption *** 29/5 emailed info Sheena Staples Dog Photographer of the Year award 1st-rescue-dogs-anne-geier-c.jpg 1st Place Rescue Dogs *** Local Caption *** 29/5 emailed to question phone number 29/5 emailed info with questions Anne Geier Dog Photographer of the Year award 2nd-young-pup-photographer-eilidh-shannon-c.jpg 2nd Place Young Pup Photographer *** Local Caption *** 29/5 7 years old confirmed win with father Eilidh Shannon Dog Photographer of the Year award 1st-dogs-at-work-dorine-scherpel-c.jpg 1st Place Dogs at Work *** Local Caption *** 28/5 need new number emailed 29/5 confirmed win and emailed info Dorine Scherpel Dog Photographer of the Year award 2nd-i-love-dogs-because-luca-gombos-c.jpg 2nd place I Love Dogs Because *** Local Caption *** 28/5 need new number, emailed 29/5 emailed info Luca Gombos Dog Photographer of the Year award 1st-puppies-monica-van-der-maden-c.jpg 1st Place Puppies *** Local Caption *** 24/5 confirmed win 29/5 emailed info Monica van der Maden Dog Photographer of the Year award 2nd-portrait-ria-putzker-c.jpg 2nd Place Portrait *** Local Caption *** 29/5 emailed info Ria Putzker Dog Photographer of the Year award 2nd-mans-best-friend-alexandra-novitskaya-c.jpg 2nd Place Man's Best Friend *** Local Caption *** 28/5 no english 29/5 emailed info Alexandra Novitskaya Dog Photographer of the Year award 1st-young-pup-photographer-sabine-wolpert-c.jpg 1st Place Young Pup Photographer *** Local Caption *** 29/5 emailed info Sabine Wolpert Dog Photographer of the Year award 2nd-rescue-dogs-tiahang-zhang-c.jpg 2nd Place Rescue Dogs *** Local Caption *** 29/5 emailed about phone number 29/5 emailed info with questions 10/6 confirmed win, moved back to China Tiahang Zhang Dog Photographer of the Year award 2nd-oldies-cat-race-c.jpg 2nd Place Oldies *** Local Caption *** 28/5 confirmed win 29/5 emailed info Cat Race Dog Photographer of the Year award 1st-i-love-dogs-because-mariah-mobley-c.jpg 1st place I Love Dogs Because *** Local Caption *** 28/5 12 years of age, confirmed win with mom Kim Mariah Mobley Dog Photographer of the Year award 3rd-dogs-at-play-angela-blewaska-c.jpg 3rd Place Dogs at Play *** Local Caption *** 28/5 LM 29/5 emailed info Angela Blewaska Dog Photographer of the Year award 3rd-puppies-lotte-van-alderen-c.jpg 3rd Place Puppies *** Local Caption *** 29/5 emailed info Lotte van Alderen Dog Photographer of the Year award 1st-mans-best-friend-cat-race-c.jpg 1st Place Man's Best Friend *** Local Caption *** 24/5 LM 28/5 confirmed win 29/5 emailed info Cat Race Dog Photographer of the Year award 3rd-dogs-at-work-nadezhda-ivanova-c.jpg Nadezhda Ivanova Dog Photographer of the Year award 2nd-puppies-carlos-aliperti-c.jpg 2nd Place Puppies *** Local Caption *** 29/5 emailed info Carlos Aliperti Dog Photographer of the Year award 3rd-oldies-susan-lang-c.jpg 3rd place Oldies *** Local Caption *** 24/5 spoke to Susan confirmed win 29/5 emailed info Susan Lang Dog Photographer of the Year award 3rd-rescue-dogs-luciana-veras-c.jpg 3rd Place Rescue Dogs *** Local Caption *** 29/5 emailed info Lu Veras Fotografia www.luverasfotografia.com.br Facebook /luverasfotografia Instagram @luverasfotografia (21) 99912-5711 Luciana Veras Dog Photographer of the Year award 3rd-mans-best-friend-michele-mccue-c.jpg 3rd Place Man's Best Friend *** Local Caption *** 28/5 LM 29/5 confirmed win and emailed info Michele Mccue Dog Photographer of the Year award 3rd-i-love-dogs-because-flora-wilson-c.jpg 3rd place I Love Dogs Because *** Local Caption *** 28/5 confirmed win, 16 yrs of age need updated file with camera details 29/5 emailed info Flora Wilson Dog Photographer of the Year award 3rd-assistance-dogs-melissa-bastin-c.jpg 3rd Place Assistance Dogs *** Local Caption *** 28/5 NA Melissa Bastin Dog Photographer of the Year award 2nd-dogs-at-work-katie-behan-c.jpg 2nd Place Dogs at Work *** Local Caption *** 28/5 confirmed win working ESS 29/5 emailed info Katie Behan Dog Photographer of the Year award 1st-assistance-dogs-angelika-elendt-c.jpg 1st Place Assistance Dogs *** Local Caption *** 24/5 spoke and confirmed win, english is not that good 29/5 emailed info info@elfmet.de Angelika Elendt Dog Photographer of the Year award 2nd-dogs-at-play-zoltan-kecskes-c.jpg 2nd Place Dogs at Play *** Local Caption *** 28/5 confirmed win 29/5 emailed Zoltan Kecskes Dog Photographer of the Year award 2nd-assistance-dogs-tracy-allard-c.jpg 2nd Place Assistance Dogs *** Local Caption *** 29/5 confirmed win, emailed info Tracy Allard

When that tactic didn’t work, Mathis attempted to pull the dog’s collar off - before realising that the collar was secured with a buckle. Eventually he was successful in freeing the dog.

“I was fighting all that fur, it took me a few tries because that dog was so fluffy,” he recalled.

Since sharing video of the incident, Mathis has been applauded for his heroic efforts.

“You should be so proud of yourself for realising what was about to happen and taking quick action!” one person wrote on Twitter. “Those quick reflexes are reflective of a naturally good heart.”

Another said: “Seriously thank you so much for not even hesitating to save that dog.”

And while Mathis says he is grateful he was there to rescue the dog, and for the “support and kind words,” he doesn’t believe the owner is at fault - and instead wants the incident to serve as a teaching moment.

"I really feel bad for the girl, she’s gotten a lot of hate," he said. "I didn’t realise how much backlash there might be for her. We’re all human, things happen like that. It just takes a second for your attention to not be there."