Referring to her love of horse racing, Archbishop of York Stephen Cottrell said she is "still in the saddle", even though she was not able to attend.
The Duke and Duchess of Sussex joined for their first royal event together since leaving the UK two years ago.
Meanwhile, the Queen, 96, watched the service from Windsor Castle.
Her decision to miss the service came after she experienced "discomfort" during Thursday's events.
It was later announced she would not attend the Epsom Derby on Saturday - and would instead watch the event on television.
Prince Andrew was forced to withdraw from attending the thanksgiving service after a positive Covid test.
As Prince Harry and Meghan arrived in St Paul's Churchyard, they received a huge cheer from the crowd, after keeping a low profile on Thursday.
NHS workers, honours recipients, public servants and charity representatives were among those at the service - part of four days of events marking the Queen's unprecedented 70-year reign.
Notable guests included Prime Minister Boris Johnson, who arrived to boos and cheers, and his wife, Carrie.
Labour leader Sir Keir Starmer, and former prime ministers John Major, Tony Blair, Gordon Brown, David Cameron and Theresa May were there. The leaders of the UK's devolved administrations were also in attendance.
Mr Johnson gave a reading from St Paul's Epistle to the Philippians in the New Testament, beginning: "Rejoice in the Lord always".
The sermon was given by the Archbishop of York after Justin Welby, the Archbishop of Canterbury, tested positive for coronavirus last week.
Referencing the Queen's love of horse racing and Saturday's Epsom Derby - which will mark the Jubilee - Mr Cottrell praised the monarch's endurance over her reign.
He said: "Your Majesty, we're sorry you're not with us this morning in person, but you are still in the saddle. And we are all glad that there is still more to come.
"So, thank you for staying the course. Thank you for continuing to be faithful to the pledges you made 70 years ago. Thank you for showing us how service and faithfulness matter. People of all faiths and none can learn from this."
With the Queen having to miss her own thanksgiving service, it was always going to be slightly subdued.
But it was still a cheerful gathering, with the Archbishop of York addressing his sermon to the Queen watching on television at home.
In a nod to her love of horse racing, he praised her for "staying the course" for such a long reign of duty and public service.
The sermon cantered through a number of her key interests: God; horses; and a good sense of humour.
Boris Johnson faced a mixed response from the crowd outside. But the Royal Family presented a unifying image.
Prince Harry and Meghan had seamlessly returned to a major royal event for the first time in two years.
In a sign of things to come, Prince Charles and Camilla, Prince William and Catherine, took over the main ceremonial roles, with that quartet of senior royals increasingly taking on the responsibilities of the monarch.
There were choirs, bells ringing, famous faces in the congregation, and prayers. But there was also a poignancy to the absence of the Queen, the central focus of the event.
The archbishop added the Platinum Jubilee was a time of "great rejoicing" which took place against a backdrop of "such suffering and uncertainty in our world".
But he said the Queen was an example of leaders who serve the common good with "a staunch constancy and a steadfast consistency; a faithfulness to God, an obedience to a vocation that is the bedrock of her life".
After the service, the largest church bell in the UK - the 16-tonne Great Paul - began ringing continuously for four hours.
Several royals and other guests went on to attend a reception at London's Guildhall.
Meanwhile, the Princess Royal travelled to Edinburgh Zoo where she fed penguins and met Ukrainian children, rescued from an orphanage in their war-torn country, who were taking part in an animal handling session.
Princess Anne's visit to the Scottish capital comes as members of the Royal Family visit the nations of the UK over the long weekend to celebrate the Jubilee.
As well as marking her service to church and country, Friday's event at St Paul's was also intended to pay tribute to the Queen's efforts to foster unity among all communities.
By Helena Wilkinson in Windsor
Behind the walls of Windsor Castle, the Queen will no doubt be resting.
Two Buckingham Palace balcony appearances on the first day of celebrations clearly left her feeling very tired. That and her mobility issues meant going to St. Paul's Cathedral today proved too much of a challenge.
Instead she watched the service on TV. Tomorrow, she'll do the same for the Epson Derby.
As the monarch rests in the castle, outside the town of Windsor is buzzing. People have come from far and wide, many just for the Platinum Jubilee.
Alka Dass came with her two sons from High Wycombe. She said: "We've come especially to see the Queen. The kids wanted to have a party with the Queen. They want to see her and visit Windsor Castle".
There has even been a proposal outside the castle gates. Onlookers watched as Danny Dorsett, 28, from Weybridge asked Lauren Wallace, 27, to be his wife.
"We came here for the Jubilee. Windsor's the best place to do it", he said.
Chief Rabbi Ephraim Mirvis, who attended and who wrote a prayer for the Queen, told the BBC her interest in the faiths of others went beyond duty.
"She has genuine care, genuine interest and wants the best - certainly for our faith and for all faiths," he said.
The service was one of the key events in four days of celebrations to mark the first time a British monarch has reigned for 70 years.
On Thursday, thousands of people gathered in central London for the traditional Trooping the Colour ceremony and a spectacular fly past of Buckingham Palace.
The Queen later illuminated a globe at Windsor Castle that coincided with the lighting of thousands of beacons across the UK and the Commonwealth.
The celebrations will continue with the Platinum Party at the Palace on Saturday, a concert at Buckingham Palace featuring performances by Queen, Sir Rod Stewart and Diana Ross.
And on Sunday, 10 million people are expected to hold street parties and other celebrations.
Prince Andrew's infection was picked up during routine testing, Buckingham Palace said, meaning he would miss the St Paul's service "with regret".
The Queen has previously spoken of mobility problems and the palace confirmed ahead of the Jubilee the monarch would consider the events she felt able to attend during the four-day celebration.