Even unbelievers will attain salvation in the time of Hazrat Mahdi (as)
His [Hazrat Mahdi’s (as)] aim is to establish a moral system from which all superstitious faiths have been eliminated. In the same way that students enter Islam, so unbelievers will come to believe.
(Vizier Mustafa, Emergence of Islam, p. 171)
Through his intellectual struggle, Hazrat Mahdi (as) will eliminate all heretical beliefs. The hadith notes that Hazrat Mahdi’s (as) students, or helpers in other words, will begin living by the moral values of Islam through him. Allah will make Hazrat Mahdi (as) instrumental in everyone coming to faith. Allah will manifest His name of “Al-Hadi,” (The Guide) in his time and everyone will believe in Allah.