Allah said that Ibrahim said,
﴿ وَمِن ذُرِّيَّتِىۖ ﴾
(And of my offspring (to make leaders)) and Allah replied,
﴿ لَا يَنَالُ عَهۡدِى ٱلظَّـٰلِمِينَ ﴾
(My covenant (prophethood) includes not Zalimin (polytheists and wrongdoers)).
When Allah made Ibrahim an Imam (Leader for the faithful), he asked Allah that Imams thereafter be chosen from his offspring. Allah accepted his supplication, but told him that there will be unjust people among his offspring and they will not benefit from Allah's promise. Thus, they will neither become Imams nor be imitated (for they will not be righteous). The proof that Ibrahim's supplication to Allah was accepted is that Allah said in Surat Al-`Ankabut (29:27),
﴿ وَجَعَلۡنَا فِى ذُرِّيَّتِهِ ٱلنُّبُوَّةَ وَٱلۡكِتَـٰبَ ﴾
(And We ordained among his offspring prophethood and the Book).
Hence, every Prophet whom Allah sent after Ibrahim were from among his offspring, and every Book that Allah revealed was to them. As for Allah's statement,
﴿ قَالَ لَا يَنَالُ عَهۡدِى ٱلظَّـٰلِمِينَ ﴾
((Allah) said, "My covenant (prophethood) includes not Zalimin (polytheists and wrongdoers). '')
Allah mentioned that there are unjust people among the offspring of Ibrahim, and they will not benefit from Allah's promise, nor would they be entrusted with anything, even though they are among the children of Allah's Khalil (intimate friend, Prophet Abraham). There will also be those who do good among the children of Ibrahim, and these it is who will benefit from Ibrahim's supplication. Ibn Jarir said that this Ayah indicated that the unjust shall not be Imams for the people. Moreover, the Ayah informed Ibrahim that there will be unjust people among his offspring. Also, Ibn Khuwayz Mindad Al-Maliki said, "The unjust person does not qualify to be a Khalifah, a ruler, one who gives religious verdicts, a witness, or even a narrator (of Hadiths).''
﴿ وَإِذۡ جَعَلۡنَا ٱلۡبَيۡتَ مَثَابَةً۬ لِّلنَّاسِ وَأَمۡنً۬ا وَٱتَّخِذُواْ مِن مَّقَامِ إِبۡرَٲهِـۧمَ مُصَلًّ۬ىۖ ﴾
(125. And (remember) when We made the House (the Ka`bah at Makkah) a place of resort for mankind and a place of safety. And take you (people) the Maqam (place) of Ibrahim (or the stone on which Ibrahim as a place)