All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ʻalayhi wa sallam, is His slave and Messenger.
The hadith which says, “The killer of ʻAmmaar and the one who will take his belongings (sword, shield, etc.) will be in Hellfire,” was cited by Al-Haakim and others. Scholars of Hadith held different views on whether it is authentic or weak. Among those who classified it as authentic was Shaykh Al-Albaani in his book As-Silsilah As-Saheehah.
Assuming that it is authentic, it cannot be used to contradict the decisively authentic hadiths that say that the Companions who took part in Bayʻat Ar-Ridhwaan shall be among the people of Paradise. Rather, the Quran itself states that Allah is pleased with them. This is the reason Ibn Hazm said in Al-Fasl,
“ʻAmmaar, may Allah be pleased with him, was killed at the hands of Abu Al-Ghaadiyah Yasaar ibn Sabʻ As-Salmi, who took part in Bayʻat Ar-Ridhwaan. He was one of the Companions about whom Allah said that He knew what was in their hearts and bestowed tranquility upon them and was pleased with them (verse 48:18). Abu Al-Ghaadiyah, may Allah be pleased with him, acted upon his Ijtihaad (personal reasoning), made a mistake in this regard, committed an act of transgression, and shall receive one reward for his Ijtihaad...” [Al-Fasl]
He stated in a different occasion that Abu Al-Ghaadiyah killed ʻAmmaar ibn Yaasir and that Abu Al-Ghaadiyah was one of the first Companions who swore allegiance to the Prophet, sallallahu ʻalayhi wa sallam, under the tree. It was authentically reported that all those Companions will not enter Hellfire. Saheeh Muslim and other books of Hadith cited that Jaabir narrated that the Prophet, sallallahu ʻalayhi wa sallam, said, “None of those who took the oath of allegiance under the tree will enter Hellfire.”
This is the scholars' attitude towards the Companions; they find excuses for the actions they did based on their personal reasoning and interpretation of texts. Al-Haafith Ibn Hajar wrote after citing some hadiths about Abu Al-Ghaadiyah, the killer of ʻAmmaar, “We believe that the Companions, in those battles, acted upon their Ijtihaad and Ta’weel (they thought that they were interpreting the texts properly and acted accordingly). The mujtahid who makes a mistake earns a reward for his Ijtihaad. Since this principle is established with regard to common people, then it is established with regard to the Companions with greater reason.” [Al-Isaabah]
Allah knows best.