A 5-year-old boy survived a harrowing ordeal Tuesday after becoming locked inside a large gun safe.

Maryland firefighters were forced to break through the wall of the safe to rescue the boy who was said to be in "good spirits" after being freed.

Firefighters with the Howard County Fire Department saved the boy after responding to a report of a child locked in a safe shortly after noon.

DC FIREFIGHTERS RESCUE 6 DOGS FROM BURNING HOME, REVIVE 1 IN SWELTERING HEAT

“Crews arrived to find a large gun safe with a five-year-old child locked inside,” fire officials tweeted.

They said firefighters conducted air monitoring during the extraction operation and rescued the boy after gaining access through the rear wall of the safe.

CLICK HERE FOR THE FOX NEWS APP

“The child was evaluated and released to the parents and was in good spirits,” the officials said.