A dog was shot three times while attempting to save its owner during an armed robbery in Des Moines, Iowa.

Rex the German Shepherd was seriously injured after he attacked a gang of men who broke into the family home of 16-year-old Javier Mercado on February 21.

"I feel like if it wasn't for him, I wouldn't be here today telling you this story," said Mercado.

Mercado was upstairs alone with his loyal companion when he noticed an unfamiliar car pull into his driveway at around noon. He realised to his horror that the men were trying to break in.

"I heard the sliding door break, and it is made out of just glass so it shattered really loud," said Mercado. "My dog ran downstairs, and it just started barking and barking. I heard one guy scream, 'the dog bit me, get the dog.'"

The teenager quickly grabbed his cellphone and called emergency services while he hid in the closet.

"I could hear my dog, like, really close to me in the bathroom with me, just barking. And the man comes upstairs," said Mercado. "I heard one gunshot and several after that, and my dog just cried after every shot that hit him."

The young boy desperately wanted to help Rex but was forced to hide for nearly an hour while police arrived and scanned the area. "I thought he was dead for sure. I broke down," said Mercado.

The dog was brought by police to local veterinary hospital BluePearl where emergency surgery was performed to save its life. Rex had suffered gunshot wounds to its neck and hind legs.

The surgery came at a cost as the family who soon realised they did not have the means to cover the expense of Rex's operation.

"I was worried, my parents were worried. My dad said he was going to start working every Saturday, saving up," said Mercado.

Thankfully, friends and family pulled through for Rex. A GoFundMe page was set up to help pay the costly medical bills and its goal was quickly reached. So far $23,000 has been raised - easily beating their $10,000 target.

rex the dog
Rex the dog helped to save the life of its young owner GoFundMe