The hadeeth was narrated by al-Bukhaari (1344) and Muslim (2296) from ‘Uqbah ibn ‘Aamir, and says that the Prophet (blessings and peace of Allah be upon him) came out one day and prayed for the people of Uhud as he used to pray for the dead. Then he went to the minbar and said: “I will be there ahead of you, and I will be your witness. By Allaah, I can see my Cistern now. I am given the keys to the treasures of the earth, or the keys to the earth. By Allaah, I do not fear that you will associate others with Allaah after I am gone, but I fear that you will compete with one another for them (the treasures of the earth).”
What is meant by his praying for them (the people of Uhud) as he used to pray for the dead is his offering supplication for them with the du‘aa’ that is recited in the funeral prayer. This was seven years after they were martyred (may Allah be pleased with them).
There is nothing in the hadeeth to say that shirk (association of others with Allah) will not happen in this ummah; rather it may be understood that he did not fear it for the entire ummah, based on the fact that it has occurred among some of them, as is indicated in other texts in which he (blessings and peace of Allah be upon him) stated that some of his ummah would fall into shirk.
An-Nawawi (may Allah have mercy on him) said in his commentary on Muslim (Sharh Muslim): In this hadeeth we see the miracles of the Messenger of Allah (blessings and peace of Allah be upon him), because what it means is a foretelling that his ummah would be given the treasures of the earth, which did indeed come to pass; and that they would not all apostatise because Allah, may He be exalted, protected them from that; and that they would compete with one another for worldly gain. And all of that came to pass. End quote.
Al-Haafiz Ibn Hajar al-‘Asqallaani (may Allah have mercy on him) said: The words “I do not fear that you will associate others with Allah” mean: (I do not fear that you will do that) en masse, because that happened with some of them – may Allah protect us. This hadeeth is one of the miracles of the Prophet (blessings and peace of Allah be upon him), hence the author narrated it under the heading of the signs of Prophethood.