King Charles III spoke as he formally conferred city status on the former town which was one of eight communities awarded the honour as part of the late Queen’s Platinum Jubilee celebrations.
The ceremony was the first undertaken by the King and Queen Consort after the official period of royal mourning for the Queen ended.
In a ceremony in Dunfermline city chambers Charles said he had been “delighted” when the announcement of city status was made in May.
He spoke of his mother’s “deep love for Scotland”, describing it as “one of the foundations of her life”.
The King highlighted the new city’s “immense significance” in Scottish history as the birthplace of entrepreneur and philanthropist Andrew Carnegie.
Dunfermline is also the “burial place of kings and queens”, he noted, with Robert the Bruce, who led Scotland in a war against England in the 1300s, buried in the abbey there.
But the new King also spoke of the community, adding: “It is my hope that all those who live in, or who hail from, this very special place will feel a real sense of pride at this latest chapter in our rich history, and that this new distinction will not merely burnish the legacy of the past but will also brighten the prospect of our future.
“That would, I know, gladden my dear mother’s heart, as it certainly gladdens mine.”
Hundreds of locals turned out to greet the royal couple, with Charles telling them: “As you celebrate your well-deserved status as Scotland’s new city, I can only offer my warmest congratulations, and my heartfelt wishes for the years to come.”
Bill Henderson, 71, who was was amongst the crowds who waited to greet the King and Queen Consort, told how locals were excited the town was now becoming a city
Speaking about it, he said: “It’s a historic event.
“I was born just before the Queen was came to the throne, so she’s been my monarch my whole life. It’s just exciting.
“And especially a King Charles coming back to Dunfermline when King Charles I was born here, however long ago that was.”
Teacher Carol Williams, 52, commented: “It’s such an honour for Dunfermline to be his first visit as the new King.”
After the ceremony at the city chambers Charles and Camilla visited Dunfermline Abbey, where they saw the resting place of Robert the Bruce.