All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Consensus is one of the sources of legislation, and an authentic reference to Muslim scholars; the four Imams and others. Evidence for this is the Saying of Allaah The Almighty (which means): {And whoever opposes the Messenger after guidance has become clear to him and follows other than the way of the believers - We will give him what he has taken and drive him into Hell, and evil it is as a destination.} [Quran 4:115]
Therefore, if the believers maintain consensus over an issue, those who oppose are threatened with torment.
Further evidence is the Saying of Allaah The Almighty (which means): {And if you disagree over anything, refer it to Allaah and the Messenger.} [Quran 4:59]
In this verse, Allaah The Almighty orders Muslims to refer to the Quran and Sunnah in case of disagreement. However, if they disagree, their consensus is sufficient.
In this context, there is a famous Hadeeth narrated by Ibn ‘Umar and his father, that the Prophet, sallallaahu ‘alayhi wa sallam, said the Muslims would never agree on an error. [At-Tirmithi]
Ibn Hajar said that the above Hadeeth is a famous one that has many narrations. He added that although all of them are somewhat weak, the Hadeeth is substantiated by the two aforementioned verses. There is also a lot of relevant evidence that can be traced in books on the fundamentals of Islamic jurisprudence.
Allaah Knows best.