In a work he wrote in 487 AH (1094 CE), Imam al-Ghazali writes:
If it is said: “If someone explicitly says Abu Bakr and ‘Umar (Allah be pleased with them) are disbelievers [wa ‘l-‘iyadhu billah], then this entails that it be treated similarly to someone who anathematises any other person amongst individual Muslims or judges and the rulers after them.”
We say: This is what we say. Anathematising them is no different to anathematising others amongst individuals of the ummah and judges, even individual Muslims who are known to be Muslims, except in two things:
The first is that it entails opposing and breaching consensus. The one who anathematises someone else may not have breached a consensus that is taken into consideration.
The second is that numerous reports have been transmitted about them, promising them Jannah, praising them, judging their religion to be sound, their belief strong and their excellence over the rest of the ummah. If the reports reach someone who says this, and he still believes them to be disbelievers, he is a disbeliever, not because of his anathematisation of them (per se) but because of rejecting the Messenger of Allah ﷺ. Whoever deems even one statement of his ﷺ to be false is a disbeliever by consensus. Without considering rejection of these reports and breaching consensus, anathematising them is treated similarly to that of all other judges, rulers and individual Muslims. (Fada’ih al-Batiniyyah, Dar Faris, pp.346-7)