The royal couple chatted with actors Ryan Reynolds and Rob McElhenney and players on the pitch and learned about the football club's redevelopment.
King Charles and Queen Camilla were in Wrexham to formally confer city status.
It is one of eight places around the UK which became a city this summer as part of the Queen's Platinum Jubilee.
The event came a day after the launch of the Netflix series Harry & Meghan provoked intense renewed interest in the Royal Family.
The King and Queen
Consort walked through the players' tunnel, and were accompanied onto the pitch by Reynolds and McElhenney.
The two actors bought the oldest club in Wales in 2021, with the goal to grow the team and return it to the English Football League.
Reynolds and McElhenney joked that they had etiquette lessons beforehand.
The club's oldest fan, 97-year-old Alex Massey, was also seen chatting with the King, while the royal couple also met Wrexham AFC disabled liaison officer, Kerry Evans.
She said : "It's very, very special, what an honour, the King and Camilla both said it's absolutely amazing the work we've been doing here.
"I never thought we'd have royalty at the club, now we've had Hollywood royalty and real royalty!"
As well as the Racecourse, the couple visited St Giles' Church and went on an impromptu walkabout in Wrexham city centre.
Hundreds lined the streets to greet the royal visitors, despite the freezing temperatures.
Charles shook hands and asked about the cold before telling the crowds to "have a stiff drink".
The couple then met Wales' First Minister Mark Drakeford before moving into the church for a service to mark Wrexham becoming a city.
During that, the King formally marked the conferral of city status.
He told the congregation he and Camilla were delighted to be there to celebrate its designation.
"City status was granted to eight different communities in order to celebrate my late mother's platinum jubilee," he said.
"As we now mark this historic occasion, we also look back, with mingled sadness and pride, at that extraordinary reign, during which, as you know, my mother's great love for Wales was always apparent."
Charles said the church "truly deserves" its designation as one of the "Seven Wonders of Wales".
He said: "A little earlier today, I had the opportunity to see one of the other wonders of Wrexham, namely the football club, which is busy putting Wrexham on the map as never before.
"And, of course, this comes after the Welsh national team has brought unprecedented international recognition to Wales through qualifying for the World Cup.
"The motto of Welsh football - gorau chwarae, cyd chwarae - sums up the spirit of community, and of joint endeavour, which is so important to Wales, and which, over the years, I have come to know and value more than I can possibly say."
"Gorau chwarae, cyd chwarae" means "team play is the best play".
Wrexham is now Wales' seventh city, joining Bangor, Cardiff, Newport, St Davids, St Asaph and Swansea.
The bid was Wrexham's fourth attempt to become a city following three failed attempts in 2000, 2002 and 2012.
The royal couple also saw the church's treasures, which include a first edition King James Bible and an early 14th Century chalice which is still in use.
In September the King and Queen Consort made their first visit to Wales since Charles became monarch in Cardiff.
Watch: King Charles and Queen Camilla met Ryan Reynolds and Rob McElhenney on Wrexham's pitch