All praise is due to Allah, and may peace and blessings be upon the Messenger of Allah.
There is no contradiction between these texts, because the end times will pass through several stages. During one stage, faith and Islam will prevail. Then another stage will follow in which the believers will pass away, and the Hour will come upon the worst of people.
After the emergence of the False Messiah (the Dajjal), Jesus, son of Mary (peace be upon him), will descend and kill him. Islam will prevail, justice and security will spread, and wealth will become so abundant that people will find no one willing to accept it. Enmity and hatred will disappear.
After this stage, the number of believers will decrease, and Allah Almighty will send a pleasant wind that will take the souls of everyone who has even a trace of faith in their heart. Only the worst of people will remain.
The Prophet Muhammad (peace and blessings be upon him) said:
“The Hour will not come until it is no longer said on earth: ‘Allah, Allah.’” Narrated by Muslim.
In the hadith of Abdullah ibn Amr (may Allah be pleased with them both), it is reported that after the destruction of the Dajjal and a period of security and peace, Allah will send a cold wind from the direction of Syria. It will take the souls of those who have even an atom’s weight of goodness or faith in their hearts. The worst of people will then remain, worshipping idols, and afterward the Trumpet will be blown.
In the hadith of al-Nawwas ibn Sam'an (may Allah be pleased with him), it is reported that this will occur after the descent of Jesus (peace be upon him), the emergence of Gog and Magog, and the spread of blessings and goodness. Allah will then send a pleasant wind that will take the souls of the believers. “The worst of people will remain, and upon them the Hour will come.”
Therefore, saying that the Hour will come upon the worst of creation does not mean that the believers will disappear before the emergence of the Dajjal or the descent of Jesus (peace be upon him). Rather, the end times will first pass through a stage in which Islam prevails and goodness becomes widespread. After that, a stage will come in which all the believers will pass away, and the Hour will come upon those who remain among the worst of people.
We ask Allah Almighty to keep us steadfast in faith and obedience until we meet Him.
And Allah Almighty knows best.