A two-year-old German Shepherd went above and beyond to protect his owner after he took bullets and blows defending his best friend from home invaders.

The 16-year-old owner, Javier Mercado, hid in his closet with his dog Rex as burglars ransacked his Des Moines, Iowa, home Wednesday, KWCH reported.

“As soon as he heard the window shatter, he ran downstairs full charge,” Mercado told KOMO. “And then I just heard a bunch of barking and struggling, and then one of the guys screaming, ‘The dog! The dog bit me! Get the dog!’”

Rex, sensing there was danger in the house, ran downstairs to confront the burglars—who ruthlessly beat him.

As the burglars continued to pilfer through the house, they approached the room where the teen was hiding. Although Rex had little strength left in him, he pounced on the burglars.

“I think if it wasn’t for him, I probably wouldn’t be standing here today,” Mercado said.

The hero German Shepherd was shot three times trying to take down the burglars.

Once the burglars heard police sirens, they fled the scene. When the officers arrived at the home, they rushed Rex to a local veterinarian, expecting the worst because they thought the animal was dead.

Doctors gave the dog pain medication, wound care, and antibiotics while placing him in intensive care. The German Shepherd is now recovering and in stable condition.

A family member set up a GoFundMe page to raise money to pay for Rex’s veterinary bills. The page raised $58,161 as of Sunday afternoon—more than five times the page’s $10,000 goal.