If you read the first part of the passage where Ibrahim is...
If you read the first part of the passage where Ibrahim is disputing with his own uncle[^1] against idol-worshipping and also Allah's statement that “We were showing…so that he might be of those who are sure [of their faith],” it shows that he was a true believer before he engaged in debate with the idol- and nature-worshippers. Even the passage where he says, “ If my Lord had not guided me, then I shall surely be of the people who have gone astray ,” is a conditional statement.
It says “if” and “then”. And since the first part did not take place, therefore the second part is not relevant. Chapter 21 (al-Anbiya') verses 62-63 In pursuant of his mission against idol-worshipping, Ibrahim one day smashed all the all idols of the temple except the big one. Then the Qur'an says: [The idol-worshippers] said, “Who has done this to our gods?
He surely must be one of the unjust people.” [Some of them] said, “We have heard a youth speaking [ill] of them, and he is known as Ibrahim.”… [When Ibrahim was brought to the king,] he said, “Rather it was this their leader that has done it— ask the [smashed idols] if they can speak.” The objection against 'ismah is that if Ibrahim was ma'sum, how could he lie?
Again, if we look at the entire passage, we see that Ibrahim wanted to make his people realize that idols are not worth worshipping—if they cannot defend themselves or even talk, then how can they help you. Secondly, Ibrâhím's answer is conditional: ”…if they can speak.” Ibrâhím's answer was rhetorical and intended to force the people to think.
This becomes clearer from the following verse: 21:65-66 …They said, “You know that the idols do not speak.” Ibrahim said, “Well then, do you worship, besides Allah, [the idols] that neither benefit you in any way nor harm you.” Chapter 2 (al-Baqarah) Verse 260 And [remember] when Ibrahim said, “My Lord!
Show me how You give life to the dead.” Allah said, “What, do you not believe [in resurrection]?” He answered, “Certainly [I believe, I am asking this] so that my heart may be at ease.” Allah said, “Take four of the birds….” Some people use this incident as a proof that Ibrahim did not believe in resurrection. This is absolutely incorrect. The question and answer are themselves very obvious that he believed. “Certainly [I believe].” Then why did he ask for a demonstration of resurrection?
Firstly, Ibrahim surely believed in God's power of giving life to dead.