A 5-year-old boy is being hailed a hero after he used what he learned during a fire safety demonstration to save himself and his grandmother from a fire in their Southern California home.

Just before 1:00 a.m. on Saturday, Nathaniel Stocks awoke to a fire burning in his room. He crawled beneath the smoke and up the hallway to alert his grandmother of the fire, San Bernardino County fire officials said.

Firefighters from the San Bernardino County Fire Department responded to the fire in the 3900 block of Sacramento Road near the community of Phelan.

Crews were met by Nathaniel and his grandmother, who said everyone was out of the home except the family dog, a Chihuahua. Firefighters rescued the pet, who was found hiding in the bathroom.

Just two days before, Nathaniel was among a group of 100 kindergartners from Phelan Elementary School who visited County Fire Station 10 in Phelan. All the students were given a station tour and lessons on fire safety.

"Because of this young hero's actions, both he and his grandmother were able to escape the growing inferno," the SBCFD said in a press release.

A preliminary investigation determined the origin of the fire to be a space heater placed too close to combustible materials, fire official said.

The fire was knocked down in approximately 15 minutes. No injuries were reported.