Kate and William joined an exercise class at Aberavon leisure and fitness centre in Aberavon, South Wales.
They were challenged to see who could cycle the farthest in 45 seconds while riding uphill in the Italian mountains.
Kate won a small trophy after emerging victorious from the Tour de Aberavon – although the distance she won by was not revealed.
Entering the cycling room, William apologised to the cyclists and said: “Sorry for ruining your spin class.”
Before climbing on to his bike, the Prince joked to his wife: “You have got high heels on.”
The Princess, who was wearing a cream top, checked skirt and black boots, said: “Not sure I am dressed for this.”
During the race, Kate adjusted the gears and laughed: “Can I make it harder?”
After finishing, William, who was breathing deeply, joked: “Talk to you in a minute.”
The royal couple took part in the cycle race during a day of engagements in South Wales ahead of St David’s Day.
At the leisure centre, they met by members of the Aberavon Swimming Club who use the 25-metre pool for training.
They then toured the sports hall and met children from Tywyn Primary School who were taking part in a range of indoors sports, including athletics and gymnastics.
Also present were Welsh professional athletes, including Harrison Walsh and Hannah Brier, who were joining the session.
Seven-year-old Rafael Vazquez, from Swansea, presented the Prince and Princess with a set of Welsh leotards for their children, Princes George and Louis and Princess Charlotte.
His mother Jo Vazquez said: “It was wonderful to meet them. They are so genuine people and have a real interest in the community, children and sport.
“They said how interested they were in keeping leisure centres open, especially swimming, as it is such a key skill for life.”
Upon leaving, William and Kate spent time meeting some of the 300 members of the public who had gathered outside to catch a glimpse of the royal couple and take selfies.
Sienna David, a member of Aberavon Swimming Club, presented the princess with a bouquet of sunflowers.
The 12-year-old from Port Talbot said: “It was amazing – really great experience.”
She spoke to William for a few minutes and described their conversation, saying he was concerned she was wearing a T-shirt in the cold weather.
“He was saying it was very cold and he asked me what my favourite swimming stroke was,” she added.
Leisure centre manager Chris Pugh said the visit was “absolutely fantastic and amazing”.
“We were delighted to be able to showcase what we do here and the part we play in supporting the community,” he said.
“There is something here for everyone in the community, whether it is swimming, fitness or sport.”