The Good Example of Ibrahim and His Followers, when They disowned Their Disbelieving People
Allah the Exalted says to His faithful servants, whom He commanded to disown the disbelievers, to be enemies with them, and to distant themselves and separate from them:
Indeed there has been an excellent example for you in Ibrahim and those with him,
meaning, his followers who believed in him
when they said to their people: "Verily we are free from you..."
meaning, `we disown you,
and whatever you worship besides Allah: we rejected you,
meaning, `we disbelieve in your religion and way,
and there has started between us and you, hostility and hatred forever
meaning, `Animosity and enmity have appeared between us and you from now and as long as you remain on your disbelief; we will always disown you and hate you,
until you believe in Allah alone
meaning, `unless, and until, you worship Allah alone without partners and disbelieve in the idols and rivals that you worship besides Him.
(except the saying of Ibrahim to his father: "Verily, I will ask forgiveness (from Allah) for you...")
means, you have a good example in Ibrahim and his people; as for Ibrahim's prayers for Allah his father, it was a promise that he made for his father. When Ibrahim became sure that his father was an enemy of Allah, he declared himself innocent of him. Some of the believers used to invoke Allah for their parents who died as disbelievers, begging Him to forgive them. They did so claiming that Ibrahim used to invoke Allah to forgive his father.
Allah the Exalted said in reply,
It is not for the Prophet and those who believe to ask Allah's forgiveness for the idolators, even though they be of kin, after it has become clear to them that they are the dwellers of the Fire (because they died in a state of disbelief). And Ibrahim's request for his father's forgiveness was only because of a promise he made to him .But when it became clear to him that he was an enemy of Allah, he dissociated himself from him. Verily, Ibrahim was Awwah and was forbearing.
(Indeed there has been an excellent example for you in Ibrahim and those with him, when they said to their people: "Verily, we are free from you...") until..
... except the saying of Ibrahim to his father:
"Verily, I will ask forgiveness for you, but I have no power to do anything for you before Allah."
According to the saying of Ibn ^Abbas, Mjahid, Qatadah, Muqatil bin Hayyan, Ad-Dahhak and several others " You cannot follow Ibrahim's example as proof in the case mentioned here, as being allowed to ask Allah to forgive those who died on Shirk
Allah the Exalted said that Ibrahim and his companions, who parted with their people and disowned their way, said afterwards, while invoking Allah in humility and submission,
Our Lord! In You we put our trust, and to You we turn in repentance, and to You is the final Return
meaning, `we trust in You for all matters, we surrender all of our affairs to You, and to You is the final Return in the Hereafter,
Our Lord! Make us not a trial for the disbelievers,
1. Understanding of Mujahid and Ad-Dahhak: "Do not punish us by their hands, nor with punishment from You
2. Understanding of Qatadah and Ibn Jarir: "Do not give the disbelievers victory over us, thus subjecting us to trials by their hands. Surely, if You do so, they would then think that they were given victory over us because they are on the truth."
3. Translator Ali bin Abi Talhah from Ibn ^Abbas: Do not give them dominance over us, lest we suffer trials by their hands
Allah's statement
and forgive us, Our Lord! Verily, You, only You, are the Almighty, the All-Wise
means, `cover our mistakes from being exposed to other than You, and forgive us for what (sin) is between us and You.
Verily, You, only You, are the Almighty,
and those who seek refuge in Your majesty are never dealt with unjustly,
the All-Wise.
in Your statements, actions, legislation and decrees.
Allah the Exalted then said,
Certainly, there has been in them an excellent example for you to follow -- for those who look forward to (the meeting with) Allah and the Last Day.
for those who look forward to Allah and the Last Day.
thus encouraging the believers who believe in Allah and the Return to Him.
Then Allah says
And whosoever turns away
meaning, from what Allah has ordained,
verily, Allah is Al-Ghani, Al-Hamid.
Musa said, If you disbelieve, you and all on the earth together, then verily! Allah is Ghani, Hamid.
Ali bin Talhah reported from Ibn `Abbas, "(Ghani) is the One Who is perfectly rich." That is Allah. This is Allah's attribute that He alone is worthy of being described by; surely, He has no equal, none like unto Him. All praise is due to Allah, the One, the Irresistible.
(Hamid) means, the praiseworthy, in all His statements and actions, there is no (true) God except Him alone.
A muslim can pray for a non-muslim as long as they are alive. If they die accepting Islam, then you can pray for them. If they die without accepting Islam, then you are not permitted to pray for them. Allah knows the best.