As with the Prophet Ibrahim (as), Imam Mahdi (as) will also EMERGE SAFELY FROM THE BURNING FLAMES. Mikyaal al-Makaarem, Vol. 1, p. 181 |

In accordance with the verses, “For truly with hardship comes ease; truly with hardship comes ease” (Surat al-Inshirah, 5-6), Allah always makes things easy for people who have a great love for Him and who live for His approval alone, and makes His mercy, love and protection felt at all times by helping them in their difficulties.
For example, the Prophet Ibrahim (as) wished to save the society he lived in from its heretical beliefs, and was exposed to severe pressure from the tribe for calling on them to adopt the religion of Allah and proper moral values. Indeed, the hostility of the community reached such a level that they elected to cast the Prophet Ibrahim (as) into the flames and burn him. But Allah saved him from this ruthless snare by commanding the fire to “be peaceful and cool for Ibrahim!” (Surat al-Anbiya’, 69)
By saying “As with the Prophet Ibrahim (as), Imam Mahdi (as) will also EMERGE SAFELY FROM THE BURNING FLAMES” in this hadith, our Prophet (saas) compares Hazrat Mahdi (as) to the Prophet Ibrahim (as) as someone who will, WITH ALLAH’S HELP, EMERGE SAFELY FROM THE MOST DANGEROUS SNARES, THE WORST ACCUSATIONS, SLANDERS AND EVILS.