The Mustache: Shave or Trim?
There is a difference of opinion on this issue, and it is as follows:
The Hanafis are divided between the opinions of their later scholars vs. their earlier scholars, with the later scholars saying that it is to be shaved completely, and this was the opinion of Abu Ja’far at-Tahawi. Ibn ‘Abidin al-Hanafi has a section on this in his ‘Hashiyah.’
The Malikis were much stricter in this. In his explanation of ‘al-Muwatta’,’ al-Baji narrated that Malik said: “Cutting the mustache is not shaving it, and I see that the one who shaves it should be disciplined.” It was also narrated that Malik considered shaving it to be a bid’ah. Some of the Maliki scholars would not even accept the testimony of the one who shaved his mustache!
As for the Shafi’is, they consider that it should be trimmed above the upper lip, and should not be shaved off, as an-Nawawi said, in ‘al-Majmu”: “The limit of cutting the mustache is that it should be trimmed until the edge of the lip is seen, and it should not be cut from the roots. This is our madhhab.” It was also reported, however, that al-Qadi ‘Iyad said that one has the choice between the two.
As for the Hambalis, an-Nawawi also mentioned that Ahmad bin Hambal said: “If one trims it, there is no problem, and if one shaves it, there is no problem.”
The difference of opinion is based on the interpretation of the words used in the various wordings of the ahadith commanding the cutting of the mustache. There are four words used by the Prophet: qass, haff, nahk, and jazz (نهك حف قص and جز). So, some of the scholars interpreted these words to indicate isti’sal (استئصال), which means to completely remove. Conversely, others interpreted these terms to indicate trimming. There is a narration in ‘Sunan an-Nasa’i’ (5043) that specifically uses the word taqsir (تقصير), which can only mean to shorten. This could have been used as evidence to strengthen the opinion of just trimming, except for the fact that this specific narration is weak.
So, this all shows that there is room for difference of opinion with regards to how to shorten the mustache, with some of the scholars saying it is to be shaved off, and some saying it is to be trimmed.
There is one more related issue, and that is the side edges of the mustache (aka the handlebars): are they part of the beard, or part of the mustache?
The Shafi’is and Hambalis considered them to be part of the mustache, and the Shafi’is saw no problem in leaving them untrimmed, due to this being the action of ‘Umar bin al-Khattab, and due to the fact that they do not generally carry the remnants of food that has been eaten like the mustache does. The Hanafis and Malikis each have scholars that support both opinions. However, it seems that what is strongest is that they are actually part of the mustache, due to the hadith reported by Ahmad bin Hambal, and narrated by Abu Umamah, in which it was asked of the Prophet: “O Messenger of Allah, the People of the Book cut their beards, and lengthen the sides of their mustaches.” So, the Prophet said: “Cut the sides of your mustaches, lengthen your beards, and differ from the People of the Book,” and this hadith is also in ‘as-Silsilah as-Sahihah’ (1245).
Summarized from here