The Dean of Windsor paid tribute to Prince Philip's "kindness, humour and humanity" during the ceremony.
The congregation wore masks and was socially distanced in line with Covid rules, with the Queen seated alone.
The duke's children walked behind his coffin in a funeral procession, followed by a national minute's silence.
More than 730 members of the armed forces took part in the event, but there was a limit of 30 mourners inside St George's Chapel, under coronavirus rules.
Prince Philip died at Windsor Castle on Friday 9 April, aged 99.
His coffin was carried the short distance to St George's Chapel on a modified Land Rover, which the duke himself helped to design.
The funeral procession was headed by the Band of the Grenadier Guards, the Major General's party, and military service chiefs.
Princess Anne and Prince Charles made up the front row behind the vehicle, followed by Prince Edward and Prince Andrew.
Prince William and Prince Harry walked either side of their cousin Peter Phillips.
The brothers sat on opposite sides of the aisle but were seen chatting together after they left the service.
image caption
The Duke and Duchess of Cambridge were seen chatting with the Duke of Sussex after the service
IMAGE COPYRIGHT
PA MEDIA
image caption
The Queen sat alone because of coronavirus restrictions
Vice Admiral Sir Timothy Laurence and the Earl of Snowdon also walked behind the coffin, trailed by members of the duke's household staff.
The Queen, 94, travelled with a lady-in-waiting in the State Bentley at the end of the procession.
IMAGE COPYRIGHT
REUTERS
image caption
Members of the Royal Family walked behind the duke's coffin
IMAGE COPYRIGHT
PA MEDIA
A ceremonial gun fire at nine locations across the UK and in Gibraltar marked the start and end of the national minute's silence.
No planes landed or took off at Heathrow for six minutes to coincide with the silence and all major sporting events were rescheduled to avoid a clash with the funeral.
media caption
A national minute's silence was held at 15:00 BST
The funeral service was conducted by the Dean of Windsor, with the Archbishop of Canterbury pronouncing the blessing.
The Dean paid tribute to Prince Philip's "kindness, humour and humanity" and the "many ways in which his long life has been a blessing to us".
"We have been inspired by his unwavering loyalty to our Queen, by his service to the nation and the Commonwealth, by his courage, fortitude and faith," he said during his bidding.
The duke's association with the Royal Navy and love of the sea was also a focus of the service but no sermon was delivered, in line with his wishes.
The music included the 1860 hymn Eternal Father, Strong to Save, by William Whiting, which is associated with seafarers and the maritime armed services.
There was a reduced choir of four singers but the congregation did not sing, in line with coronavirus restrictions.
Buglers of the Royal Marines sounded Action Stations - a signal that all hands should be ready for battle - as the coffin was lowered into the Royal Vault at the end of the service.
IMAGE COPYRIGHT
PA MEDIA
IMAGE COPYRIGHT
PA MEDIA
image caption
The duke's insignia was displayed on the altar in St George's Chapel
Buckingham Palace said the funeral plans had been modified to take into account public health guidelines.
The funeral took place entirely within the grounds of the castle and the public were asked not to gather there or at other royal residences.
But the ceremonial aspects of the day and the service remained in line with Prince Philip's wishes and reflected his military affiliations and personal elements of his life.
Ahead of the funeral, the Queen shared a favourite photograph of herself with her husband in Aberdeenshire.
Taken by the Countess of Wessex in 2003, the picture shows the couple relaxing on a picnic rug on the grass at the Coyles of Muick beauty spot, near the Queen's private estate of Balmoral.
IMAGE COPYRIGHT
THE COUNTESS OF WESSEX
image caption
The Queen released one her favourite photos ahead of the funeral
Windsor falls silent to remember Prince Philip
by BBC reporter Harry Farley
Silence descended across Windsor High Street at 15:00 to mark the start of the duke's funeral.
The Royal Family had asked members of the public to stay away because of coronavirus restrictions. And the streets of this town were far emptier than they would otherwise have been.
But hundreds still gathered in the sun to pay their respects.
As the funeral service was under way in St George's Chapel, a short distance away in Windsor's Guildhall a wedding was coming to an end.
Mikey Durnian said he and his partner Jodie had rearranged their wedding five times because of the pandemic.
He said it had felt "strange" to learn last week that their wedding would be taking place just metres away from Prince Philip's funeral.
"Obviously we're overjoyed. This day has been in the making a long time. But obviously, there's a lot of people around to mourn."
Jodie added: "We definitely didn't want to overtake from anything that's happening today. It is a very sad occasion. But we are delighted to finally be married."
The 30 guests at the funeral wore morning coats with medals, or day dress, but not military uniform.
The Queen and duke's four children - the Prince of Wales, the Princess Royal, the Duke of York and the Earl of Wessex - and eight grandchildren attended, but none of their young great-grandchildren.
Spouses of the children and grandchildren are among the congregation, including two who have married into the family in recent years - Jack Brooksbank and Edoardo Mapelli Mozzi, husbands of Princesses Eugenie and Beatrice.
But the Duke of Sussex's wife, Meghan, is heavily pregnant and was advised by her doctors not to fly in from the US. She was said to have watched the service from home.
The other mourners included the children of the Queen's sister, Princess Margaret, and three of Prince Philip's German relatives - Bernhard, the Hereditary Prince of Baden; Donatus, Prince and Landgrave of Hesse; and Prince Philipp of Hohenlohe-Langenburg.