Allah, the Exalted said:

وَأَمَّا الْغُلامُ فَكَانَ أَبَوَاهُ مُؤْمِنَيْنِ فَخَشِينَا أَن يُرْهِقَهُمَا طُغْيَانًا وَكُفْرًا

“And as for the boy, his parents were believers, and we feared lest he should oppress them by rebellion and disbelief [18:80]

And the Prophet (ﷺ) said:

عَنْ أُبَىِّ بْنِ كَعْبٍ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ “‏ إِنَّ الْغُلاَمَ الَّذِي قَتَلَهُ الْخَضِرُ طُبِعَ كَافِرًا وَلَوْ عَاشَ لأَرْهَقَ أَبَوَيْهِ طُغْيَانًا وَكُفْرًا ‏

Ubayy b. Ka’b (may Allah be pleased with him) narrated that Allah’s Messenger (ﷺ) said: “The young man whom Khadir killed was a non-believer by his very nature and had he survived he would have involved his parents in defiance and unbelief [Saheeh Muslim no. 2662]

Shaikhul-Islam Ibn Taymiyyah (may Allah have mercy upon him) said: “That is Allah sealed him in the mother of the Book (e.g. the Lawh al-Mahfoodh). That is: He decreed him or affirmed him to be a disbeliever such that if he lived, he would commit disbelief through action” [Majmoo al-Fatawa (4/151)]

Imam Shawkaani (may Allah have mercy upon him) said:

“…It was said: that Khadir knew, through the notification of Allah, that if the boy became mature, he would be a disbeliever. His disbelief would lead to the misguidance of his parents and their disbelief…it is not permissible to kill him according to the Shariah of Muhammad. However it is permissible in another Shariah [i.e. the Shariah that Khidr was following]. So there is no issue.” [Fathul-Qadeer (3/434)]

Shaikh Abdul-Muhsin al-‘Abbad (may Allah preserve him) said:

“The boy being sealed as a disbeliever does not contradict with the Hadith that came:

كل مولود يولد على الفطرة، فأبواه يهودانه أو ينصرانه أو يمجسانه

Every child is born with a true faith of Islam (i.e. to worship none but Allah Alone) and his parents convert him to Judaism or Christianity or Magianism [Bukhari and Muslim]

The boy being sealed as a disbeliever does not mean that he was young and did not reach puberty and that nothing occurred to him which he knew. For verily the origin of the Hadith of the Fitrah is (that) it is general. This boy being sealed as a disbeliever means that it was decreed that he will be a disbeliever. It does not mean that that he was not created upon a fitrah and that he was outside of the fitrah for verily: “Every child is born with a true faith of Islam (i.e. to worship none but Allah Alone)”. This [boy] is a newborn. However, he deviated and this occurs among people. As Allah, the Exalted said:

خلقت عبادي حنفاء فاجتالتهم الشياطين

I have created My servants as one having a natural inclination to the worship of Allah [Muslim] but it the devils turned them away” [Sharh Sunan Abi Dawood no. 530]

In summary, this boy was decreed by Allah to be a disbeliever later on and Khidr (who was a Prophet according to the majority of the Scholars) was informed by Allah regarding that. So he killed him and it was not an action of his own as Allah said:

مَا فَعَلْتُهُ عَنْ أَمْرِي

And I did it not of my own accord [18:82]

So there is no evidence in this incident to call another person a disbeliever. Declaring a Muslim as a disbeliever without proof is not allowed in Islam as it comes:

عن ابن عمر رضي الله عنهما قال‏:‏ قال رسول الله صلى الله عليه وسلم ‏:‏ ‏ “‏إذا قال رجل لأخيه‏:‏ يا كافر، فقد باء بها أحدهما، فإن كان كما قال وإلا رجعت عليه

On the authority of Ibn ‘Umar (May Allah be pleased with them) said: The Messenger of Allah (ﷺ) said, “When a person calls his brother (in Islam) a disbeliever, one of them will certainly deserve the title. If the addressee is so as he has asserted, then disbelief of the man is confirmed, but if it is untrue, then it will revert to him.” [Bukhari and Muslim]

And Allah Knows Best

Faisal bin Abdul Qaadir bin Hassan
Abu Sulaymaan