Short answer
His scripture never says so. In the Great Discourse on the Buddha's Extinguishment, the account of his death, he told Cunda, the smith who fed him, to bury what was left of one dish. He said no one in the world but the Buddha could properly digest it. The very next line says that after eating it he fell badly ill, with bloody dysentery, close to death. He died soon after. Three months earlier, the same discourse says, he had hinted to his helper Ananda that he could live on. Ananda did not beg him to, and he gave up his life force. Later he told Ananda the fault was his alone. So the same scripture says he alone could digest the dish, and then that he fell gravely ill after eating it. The Qur'an has the Prophet (ﷺ) say that if he knew the unseen, no harm would have touched him.
Full explanation
A dish only the Buddha could digest
The Great Discourse on the Buddha's Extinguishment, that is, his passing away, is the Pali account of his last months. It tells of a meal at the home of Cunda the smith. The Buddha asked to be served one dish, which this translation calls pork on the turn. Then he told Cunda to bury whatever was left in a pit. He said he saw no one in the world, among gods or humans, who could properly digest it except the Realized One. That was his name for himself.
“Then the Buddha addressed Cunda, "Cunda, any pork on the turn that's left over, you should bury it in a pit. I don't see anyone in this world—with its gods, Māras, and divinities, this population with its ascetics and brahmins, its gods and humans—who could properly digest it except the Realized One."”
Then he fell ill, close to death
The next lines say that after he had eaten Cunda's meal, he fell badly ill with bloody dysentery. He was struck by dreadful pains, close to death. A verse in the discourse links the sickness to the dish he had eaten. The Buddha expected that some people would blame Cunda. They would tell him it was his misfortune that the Buddha died after eating his last meal from him. So the Buddha told Ananda how to ease Cunda's regret.
“After the Buddha had eaten Cunda's meal, he fell severely ill with bloody dysentery, struck by dreadful pains, close to death.”
“Now it may happen, Ānanda, that someone may give rise to regret in Cunda the smith: 'It's your loss, respected Cunda, it's your misfortune, in that the Realized One was fully quenched after eating his last almsmeal from you.' You should dispel remorse in Cunda the smith like this:”
He could have lived on, and blamed his helper
Three months before the meal, the same discourse says, the Buddha told Ananda he could live out a full lifespan if he wished. He hinted at this to Ananda, his helper, three times. Ananda did not beg him to stay. The text says his mind was as if taken over by Mara, the tempter in Buddhist scripture. So the Buddha gave up his life force, saying he would die in three months. And he told Ananda that the fault was his alone. The page "Did the Buddha want to teach?" sets out this exchange.
“The Realized One has developed and cultivated the four bases of psychic power, made them a vehicle and a basis, kept them up, consolidated them, and properly implemented them. If he wished, the Realized One could live for the proper lifespan or what's left of it.”
“But Ānanda didn't get it, even though the Buddha dropped such an obvious hint, such a clear sign. He didn't beg the Buddha: "Sir, may the Blessed One please remain for the proper lifespan! May the Holy One please remain for the proper lifespan! That would be for the welfare and happiness of the people, out of sympathy for the world, for the benefit, welfare, and happiness of gods and humans." For his mind was as if possessed by Māra.”
“When this was said, the Buddha said to Māra, "Relax, Wicked One. The full extinguishment of the Realized One will be soon. Three months from now the Realized One will be fully extinguished."”
“So at the Cāpāla Shrine the Buddha, mindful and aware, surrendered the life force.”
“Therefore, Ānanda, the misdeed is yours alone, the mistake is yours alone. For even though the Realized One dropped such an obvious hint, such a clear sign, you didn't beg me to remain for the proper lifespan, or what's left of it. If you had begged me, I would have turned you down twice, but consented on the third time. Therefore, Ānanda, the misdeed is yours alone, the mistake is yours alone.”
What the account shows
He said he alone could properly digest the dish. The very next line has him gravely ill after eating it, and a verse in the discourse links the sickness to the dish. If he knew it would harm him, he did not say so. If he did not know, his claim about it failed. And by the same text, whether he lived on had depended on his helper taking a hint while his mind was clouded. Then the helper was blamed. This is not the record of a teacher whose word can be trusted about things no one else can see.
“Then the Buddha addressed Cunda, "Cunda, any pork on the turn that's left over, you should bury it in a pit. I don't see anyone in this world—with its gods, Māras, and divinities, this population with its ascetics and brahmins, its gods and humans—who could properly digest it except the Realized One."”
“After the Buddha had eaten Cunda's meal, he fell severely ill with bloody dysentery, struck by dreadful pains, close to death.”
“Therefore, Ānanda, the misdeed is yours alone, the mistake is yours alone. For even though the Realized One dropped such an obvious hint, such a clear sign, you didn't beg me to remain for the proper lifespan, or what's left of it. If you had begged me, I would have turned you down twice, but consented on the third time. Therefore, Ānanda, the misdeed is yours alone, the mistake is yours alone.”
A messenger who said he did not know the unseen
The Qur'an tells the Prophet (ﷺ) what to say. He has no power over any good or harm to himself, except as God (﷾) wills. If he knew the unseen, no evil would have touched him. It calls him a man, and only a messenger, like the messengers who passed away before him. Aisha said he used to say this: no prophet falls ill without being given the choice between this world and the next. In his last illness she heard him recite the verse about the company of those God (﷾) has favoured. She understood that he had been given the choice.
“Say: "I have no power over any good or harm to myself except as Allah willeth. If I had knowledge of the unseen, I should have multiplied all good, and no evil should have touched me: I am but a warner, and a bringer of glad tidings to those who have faith."”
“Say: "I am but a man like yourselves, (but) the inspiration has come to me, that your Allah is one Allah: whoever expects to meet his Lord, let him work righteousness, and, in the worship of his Lord, admit no one as partner.”
“Muhammad is no more than a messenger: many Were the messenger that passed away before him. If he died or were slain, will ye then Turn back on your heels? If any did turn back on his heels, not the least harm will he do to Allah; but Allah (on the other hand) will swiftly reward those who (serve Him) with gratitude.”
Aisha reports that the Prophet (ﷺ) used to say that no prophet falls ill without being offered the choice between this world and the next. In his final illness, with his voice hoarse, she heard him recite the verse about being in the company of those Allah has favoured: the prophets, the sincere, the martyrs and the righteous (4:69). She understood from this that he had been given the choice.
The usual answers
Sahih al-Bukhari 4428 — Kitab al-Maghazi (Military Expeditions), hadith 4428
Aisha reports that in his last illness the Prophet (ﷺ) said he still felt the pain of the food he had eaten at Khaybar, and that it felt as if his aorta was being cut by that poison.
Cited for
The Prophet (ﷺ) also felt the pain of food he had eaten, the poisoned food at Khaybar, in his last illness.
The response
He never said that food was safe for him alone. The Qur'an has him say that if he knew the unseen, no evil would have touched him. So nothing he said about himself was shown false by it. The Buddha said he alone could digest the dish, and then fell severely ill after eating it. The page "Did Muhammad (ﷺ) die of poison, and does that make him a false prophet?" answers the claim about the verse on the heart's artery.
Where it lands — The Prophet (ﷺ) claimed no knowledge of the unseen. The Buddha made a claim about the dish that the next lines of his own scripture undo.
Perspectives
Theravada Buddhist
The meal did not decide the Buddha's death. Three months before, he had already given up the life force that kept him alive, and at eighty his body was worn out.
Three months earlier, the Buddha had already given up his life force and said when he would die. So the meal did not decide his death.
Rebuttal
That does not answer what he said about the dish. He said no one but he could properly digest it. Right after eating it he fell severely ill with bloody dysentery, close to death. The discourse ties the sickness to the meal, and the Buddha expected some to tell Cunda it was his misfortune that the Buddha died after eating it.
He was eighty and had already been gravely ill. He said his body was kept going like an old cart held together with rope. So any meal could have brought on the end.
Rebuttal
Being old does not explain his words about the dish. He told Cunda it was unfit for anyone but himself. He ate it, and the next line has him gravely ill. If his worn-out body could not bear it, then his claim that he alone could digest it could not be relied on.
The Buddha gave Ananda a clear hint that he could live on. Ananda failed to ask, so the fault was Ananda's.
Rebuttal
The text says Ananda's mind was as if possessed by Mara when he missed the hint. And the Buddha says he taught without the closed fist of a teacher who holds things back. He could have said plainly what he meant. Instead he hinted, and then blamed his helper.
What the discourse says
The Pali account puts three things in one discourse. They are the Buddha's words about the dish, his illness after eating it, and his blaming of Ananda.
The Buddha told Cunda to bury the rest of the dish. No one but the Realized One, he said, could properly digest it.
After eating Cunda's meal he fell severely ill with bloody dysentery, close to death.
The Buddha told Ananda the misdeed was his alone, for not begging him to remain for the proper lifespan.
The Islamic perspective
The Prophet (ﷺ) was a man and a messenger. He claimed no power over harm to himself, except as God (﷾) wills, and said that if he knew the unseen, no evil would have touched him.
The Qur'an has the Prophet (ﷺ) say this. He has no power to bring good or harm to himself, except as God (﷾) wills. And it has him say: if he knew the unseen, no evil would have touched him.
The Qur'an says he is a man, and only a messenger, like the messengers who passed away before him.