It is reported that Imām Mālik – Allāh have mercy on him – was asked, “Who is allowed to give religious rulings (fatwā)? He replied:

Issuing fatwā is not allowed except for a person who knows what the people have differed in. It was said, ‘Do you mean the different views of the people of opinions (those who depend more on analogy and speculation)? He replied, “No, [I mean] the different views of the Companions of Muḥammad – Allāh’s praise and peace be upon him. And he must also know the textual evidence that abrogates [other rulings] and that which is abrogated [by other texts], both in the Quran and the ḥadīth of Allah’s Messenger – Allāh’s praise and peace be upon him. Such a person can issue fatāwā.

Ibn ‘Abd Al-Barr, Jāmi’ Bayān Al-‘Ilm wa Faḍlihī article 1529.

It is reported that ‘Abdullāh b. Al-Mubārak – Allāh have mercy on him – was asked, “When can a person issue an edict (fatwā)?” He replied, “When he is knowledgeable about the narrations (hadith and traditions of the Salaf), and has insight into [juristic] opinion.

Ibid. article 1532.