The Prince of Wales and Boris Johnson were among those at the Westminster Abbey service, with the prime minister wearing a Ukraine-and-UK badge.
"It is not the first time that might has demanded to be right," Lord Sentamu said of the attack on Ukraine.
The Queen, 95, had pulled out of attending this year's service.
Lord Sentamu told the Commonwealth Service, attended by royals including the Duke and Duchess of Cambridge and senior politicians, his prayer for Ukraine was "heavenly justice will defend the poor and vulnerable".
In contrast to a "world which measures power in megatons", he said, the Queen's long reign had been about duty and service and the principle: "Whoever shall be great among you shall be your servant."
The Royal Family have been unusually outspoken over the Ukraine war, with Prince Charles condemning the "brutal aggression" and the Duke and Duchess of Cambridge visiting the Ukrainian Cultural Centre wearing badges in the Ukrainian national colours.
The ceremony, in Westminster Abbey, celebrated the work of the Commonwealth, with parades of flags, readings and music from Emeli Sandé and Mica Paris, and a focus on the Queen's Platinum Jubilee.
After concerns about her ability to travel and her mobility, the Queen had been unable to attend in person.
But in a message she praised the Commonwealth as a force for good in "these testing times".
She also showed no sign of stepping back, repeating the lifelong commitment made when she was 21 that "my life will always be devoted in service".
The Queen recently recovered from Covid and has returned to holding diplomatic meetings and audiences in person.
But in one of those meetings last month, she said: "As you can see, I can't move."
Prince Charles represented her at the Westminster Abbey service.
He will also go on behalf of the Queen to the next Commonwealth Heads of Government Meeting, due to be held in Rwanda in June.