This last view is the one that al-Tahtāwī adopts in his marginal notes to Maraqī al-Falāḥ, and his exact words are:
“His statement, ‘and in the cemetery’—with the b in maqbara permitted with any of the three short vowels—is because it resembles the practice of the Jews and Christians. The Messenger of Allah ﷺ said: ‘May Allah curse the Jews and the Christians; they took the graves of their prophets as places of worship.’ It makes no difference whether the grave is above the worshipper, behind him, or beneath the very spot on which he is standing. The graves of the prophets, peace be upon them, are excepted; praying there is never disliked, whether the grave has been opened or not, provided it is not in the direction of the qiblah, for the prophets are alive in their graves. Do you not see that Ishmael’s resting-place, peace be upon him, lies in the Ḥijr beneath the rain-spout, and that between the Black Stone and Zamzam are the graves of seventy prophets? Yet that mosque is the best place to seek out for prayer—unlike the cemeteries of anyone else.” He mentions this in his commentary on al-Mishkāt.
All of this is al-Tahtāwī’s statement, and it is flawed, one part contradicting the other. If he explicitly states that the reason for the reprehensibility is imitation of the Jews and Christians—who turned the graves of their prophets into places of worship—how can he then exempt the graves of the prophets, when the imitation of the unbelievers is realized precisely by praying there?
Yes, the exemption might have carried some weight had the cause of the censure been impurity, since the graves of the prophets are pure. Even then, however, the exemption cannot stand in any absolute sense after the Prophet ﷺ cursed those who turn the graves of the prophets into mosques and forbade his community from doing so, as will be explained.