The questioner asks, what is the ruling of requesting from the dead a prevention of harm or attaining benefit? Which of the two types does it fall into?
Shaykh Ṣāliḥ al-Ḥudaīthy:
This is major polytheism. If you call upon someone other than Allāh to accomplish something only Allāh has the ability to achieve, then this is major polytheism. Which means that you have left the fold of Islam even if you were to say “I am a Muslim.”
So long as you do this, then you are a polytheist, disbeliever and your action is incorrect. Therefore, those that go to the graves, circumambulating them, invoking them, sacrificing for them, calling upon them, then they are polytheists even if they claim to be Muslims. Up until they make their actions sincere for Allāh, repent to him, and actualise the testimony of none being worthy of worship in truth except Allāh. As for one that calls upon other than Allāh, whoever it is, then he is a polytheist even if he prays and fasts.
What if it were the Prophet ﷺ?
Even if it were the Prophet ﷺ, or even Jibrīl! Calling upon other than Allāh is major polytheism. Allāh ﷻ says: “And the places of worship are for Allāh alone, so do not invoke anyone besides Allah.” [Al-Jinn:18]. The Lord also says: “And your Lord said, “Call upon me and I will answer you…”” [Al-Ghāfir:60], “And to Allāh belong the best names, so call upon Him with them.” [Al-A’rāf:180]
The Prophet ﷺ said “Indeed, one should not seek refuge with me, but verily should seek refuge with Allāh The Exalted” (Aṭ-Ṭabarānī)
Whoever calls upon other than Allāh, regardless of who it is, then he has set up a partner with Allāh ﷻ.