In a statement shortly after midday, the palace said: “His Royal Highness passed away peacefully this morning at Windsor Castle.”
The Duke of Edinburgh, who was the longest-serving consort in British history, had returned to Windsor Castle on 16 March after a month in hospital.
Boris Johnson said he “inspired the lives of countless young people”.
“It is with deep sorrow that Her Majesty The Queen announces the death of her beloved husband,” the palace said.
“The Royal Family join with people around the world in mourning his loss.”
Speaking at Downing Street, the prime minister said that the duke had “earned the affection of generations here in the United Kingdom, across the Commonwealth, and around the world”.
Meanwhile, Justin Welby, the Archbishop of Canterbury, said he “consistently put the interests of others ahead of his own and, in so doing, provided an outstanding example of Christian service”.
The flag at Buckingham Palace was lowered to half-mast and a notice was posted on the gates following the announcement of the duke’s death.
The BBC’s royal correspondent Nicholas Witchell said it was “a moment of real national sadness” and “a moment of sadness, most particularly of course, for the Queen losing her husband of 73 years – a bigger span of years than most of us can imagine”.
He said Prince Philip had made “a huge contribution to the success of the Queen’s reign”, describing the duke as “utterly loyal in his belief in the importance of the role that the Queen was fulfilling – and in his duty to support her”.
“It was the importance of the solidity of that relationship, of their marriage, that was so crucial to the success of her reign,” he added.
A bank of photographers and cameramen were lined up around the growing number of tributes at Buckingham Palace on Friday afternoon, according to BBC News reporter Marie Jackson.
Rhea Varma, from Pimlico, pulled up to the gates on her bike to lay flowers and a note saying Rest in Peace Duke.
She said: “It’s just super sad. I think it might be the beginning of big change in our country. Without him, the Queen might not reign much longer.”
To her, the duke was “the kind of stability that’s so old-fashioned it’s difficult to comprehend. He was a rock who brought integrity.”
The prince married Princess Elizabeth in 1947, five years before she became Queen.
In March, the duke left King Edward VII’s hospital in central London after a month-long stay for treatment.
He underwent a procedure for a pre-existing heart condition at another London hospital – St Bartholomew’s.