Some evidence from the Quran and Sunnah that scholarly consensus (ijma`) constitutes definitive proof
Question

What is the evidence from the Quran and Sunnah that scholarly consensus (ijma`) may be used as evidence when working out Islamic rulings?
Praise be to Allah.Sound scholarly consensus (ijma`) is one of the sources of Islamic legislation. So when it is proven that there is scholarly consensus, that constitutes binding shar`i proof and no one has the right to go against it.
Please see the answers to questions no. 112268 and 131935.
The fact that scholarly consensus (ijma`) may be used as evidence is supported by many texts of the Quran and Sunnah.
Evidence from the Holy Quran:

{But whoever opposes the Messenger after guidance has become clear to him, and follows a path other than that of the believers, We will leave him to that which he himself has chosen and cast him into hell – an evil journey’s end} [an-Nisa’ 4:115].

Ibn Kathir (may Allah have mercy on him) said:
The evidence on which ash-Shafa`i based his argument to support his view that consensus constitutes definitive proof that it is prohibited to go against is this verse, and he reached this conclusion after lengthy deliberation and thought. This is the best and strongest conclusions regarding this issue. (End quote from Tafsir Ibn Kathir, 2/413)
The conclusion reached from the verse is based on the fact that Allah, may He be exalted, issued a warning of punishment to those who follow a path other than that of the believers. This indicates that it is obligatory to follow the path of the believers, which is what the believers unanimously agree upon.

{Thus We have made of you an Ummah [nation, community] justly balanced, that you might be witnesses over humankind, and the Messenger might be a witness over you } [al-Baqarah 2:143].

Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said: What is meant by al-wasat [translated here as justly balanced] is what is fair and best. Allah has made them witnesses over humankind and has made their testimony equal to the testimony of the Messenger. It is soundly narrated in as-Sahih that a funeral passed by the Messenger of Allah (S) and the people spoke well of the deceased, so he said: “It has become certain, it has become certain.” Then another funeral passed by him and they spoke ill of the deceased, so he said: “It has become certain, it has become certain.” They said: O Messenger of Allah, why did you say,It has become certain, it has become certain? He said: “For the one of whom you spoke well, I said: Paradise has become certain for him, and for the one of whom you spoke ill, I said: Hell has become certain for him. You are the witnesses of Allah on earth.”
As Allah has made them witnesses, they cannot give false testimony. If they testify that Allah has enjoined something, then He must have enjoined it, and if they testify that Allah has forbidden something, then He must have forbidden it. If they were capable of giving false or wrong testimony, they would not be the witnesses of Allah on earth. Rather Allah has praised them and their testimony as He praised the prophets for what they conveyed from Him, by confirming that they (the prophets) would not say anything about Him except what is true, and thus the ummah will not say in testimony regarding what Allah has permitted and prohibited anything except what is true. Moreover, Allah, may He be exalted, says (interpretation of the meaning): {and follow the way of those who turn to Me} [Luqman 31:15]. The ummah constantly turns to Allah, so it is obligatory to follow their path. (End quote from Majmu` al-Fatawa, 19/177-178)

{If you are in dispute over any matter, refer it to Allah and His Messenger, if you [truly] believe in Allah and the Last Day} [an-Nisa’ 4:59].

The words {If you are in dispute over any matter, refer it} indicate that with regard to that on which they are agreed, there is no need to refer it to the Quran and Sunnah, because it is sufficient to refer to the consensus that has been reached.
Evidence from the Sunnah

The report narrated by at-Tirmidhi (2167) from Ibn ‘Umar (may Allah be pleased with him), according to which the Messenger of Allah (blessings and peace of Allah be upon him) said: “Indeed Allah will not cause my ummah to unanimously agree on misguidance, and the hand of Allah is with the main body of the Muslims (jama`ah).” Al-Albani classed it as authentic in Sahih at-Tirmidhi.

Ibn Abi `Asim narrated in as-Sunnah (83) from Anas ibn Malik that the Prophet (blessings and peace of Allah be upon him) used to say: “Allah has protected my ummah from agreeing on misguidance.”
Al-Albani classed it as authentic in Sahih al-Jami` (1786).
In more than one hadith, the Messenger (blessings and peace of Allah be upon him) enjoined adhering to the main body of the Muslims (jama`ah) and forbade differing from them and splitting from them, as in the hadith in which he (blessings and peace of Allah be upon him) said: “Whoever splits away from the jama`ah (main body of Muslims) by a handspan and dies (in that state), that is a death of Jahiliyyah (ignorance).” (Narrated by al-Bukhari, 7143 and Muslim, 1849). And he (blessings and peace of Allah be upon him) said: “Whoever separates the distance of a handspan from the jama`ah (main body of Muslims), has lost his connection with Islam.” (Narrated by Abu Dawud, 4758; al-Albani classed it as authentic in Sahih Abi Dawud)
Imam ash-Shafa`i (may Allah have mercy on him) said:
The fact that the Messenger of Allah (blessings and peace of Allah be upon him) instructed the Muslims to adhere to the main body of the Muslims (jama`ah) is among the evidence that the consensus of the Muslims – in sha Allah – is binding. (End quote from ar-Risalah, 1/403).
Ibn Qudamah (may Allah have mercy on him) said:
These reports were widely known and famous among the Companions and the Successors of the Companions, and none of the earlier or later generations rejected them. Even though they do not reach the level of being mutawatir, when they are taken as a whole, we inevitably conclude that the Prophet (blessings and peace of Allah be upon him) explained the high status of this ummah and stated that it is collectively infallible and will not err. (End quote from Rawdat an-Nazir, 1/387)
This is some of the evidence that the scholars quote from the Quran and Sunnah to affirm that consensus constitutes shar`i proof.
Shaykh Ibn `Uthaymin (may Allah have mercy on him) said:
The consensus of the ummah is either right or wrong. If it is right, then their consensus constitutes proof, and if it is wrong, then how could this ummah, which is the dearest of nations to Allah since the time of its Prophet until the onset of the Hour, agree on something that is wrong and is not pleasing to Allah? This is utterly impossible. (End quote from Majmu` Fatawa wa Rasa’il al-`Uthaymin, 11/63.
And Allah knows best.