Thus, we supplicate for the Messenger, peace and blessings be upon him, to be kept safe from the terrors of that standing. We may also say that it has a broader meaning: peace upon him includes the safety of his law and sunnah, protecting them from being tampered with by those who would manipulate them. This is like what the scholars said concerning Allah’s words: “If you differ over anything, refer it to Allah and the Messenger.” [al-Nisā’ 4:59] They said: refer it to him during his lifetime, and to his sunnah after his death.
Peace be upon you, O Prophet...
His statement, “Peace be upon you”: Is this a declarative statement or a supplication? That is, are you stating that the Messenger has been granted safety, or are you supplicating that Allah grant him safety?
The answer is that it is a supplication—that you ask Allah to grant him safety. It is a declarative statement intended as a supplication; because of the firm hope that it will be answered, it is phrased as an accomplished fact.
Is this then an address to the Messenger, peace and blessings be upon him, like people addressing one another?
The answer is no. If it were so, it would invalidate the prayer, for no ordinary human speech is permitted in this prayer. Moreover, if it were so, the Companions would have said it aloud so that the Prophet, peace and blessings be upon him, could hear them, and he would have returned their greeting, just as he did when they met him. Rather, as Shaykh al-Islam said in his book Iqtida al-Sirat al-Mustaqim (The Requisite of the Straight Path): because you vividly recall the Messenger, peace and blessings be upon him, when greeting him, it is as though he were before you and you were addressing him.
For this reason, the Companions would say, “Peace be upon you,” while he did not hear them; and they would say, “Peace be upon you,” while they were in one town and he was in another. We too say, “Peace be upon you,” while we are in a land other than his and in an age other than his.
As for what is narrated in Sahih al-Bukhari from Abdullah ibn Mas'ud