The Queen is, for the first time, to visit the Scottish mansion bought for £45 million and restored by her son, Prince Charles.

The monarch will see the fruits of the Duke of Rothesay's investment and labours at Dumfries House in Ayrshire, on Wednesday, which he bought through a trust for £45m in 2007.

The purchase of the Palladian masterpiece, designed in the 1750s by John, Robert and James Adam, the pre-eminent architects of the Scottish Enlightenment - was due to have been sold by private auction along with 1945 acres of landscaped grounds and farmland and its collection of Thomas Chippendale furniture before the Duke stepped in and established a charitable trust to save the house.

The Queen will be making her first visit to the mansion, which re-opened to the public in 2008.

She will be seeing its education centre, cookery school, craft skills training as well as its restored walled garden.

Inside the house, built for the 5th Earl of Dumfries, she will see the revamped Pewter Corridor, the Blue Dining Room and the Pink Dining Room.

The Queen will view what the Trust that runs the house believe is an example of "heritage led regeneration", not only of the house but of the surrounding area.

The visit will be one of a series of engagements for the Queen in Scotland this week, which will include the naming of the HMS Queen Elizabeth at the Royal Dockyard in Rosyth.

The main purpose of her visit to Dumfries House will be to see the Walled Garden, which is the second largest in the UK, and opens to the public next month.

The Duke has encouraged donations to the trust by some of the world's wealthiest individuals.

Last month the world's second richest man, Carlos Slim, the Mexican business magnate, stayed at the house.

In four years the Duke has raised £19m for the house from private donations. He said he likes to quote the remarks made by the 5th Earl about the house.

"'Tis certainly a great undertaking, perhaps more bold than wise, but necessity has no law'. I felt rather the same 250 years later," the Duke has been quoted saying.

In October 2011, after many years of neglect, an extensive volunteer effort was launched to clear the large garden site of rubbish and overgrowth as it was "in a very sorry state".

The fourth wall that had been originally constructed had fallen down some 100 years before, and few formal plans of the garden existed.

The garden is located on a site formerly known as Wattersyde (Waterside) that originally had a house and kitchen garden.

An Education Centre near the garden has been running for two years and is used by 3000 primary school children every year.

Dumfries House now employs 55 permanent staff and an additional 25 seasonal staff at the house, which costs £600,000 a year to run.

It has also become a wedding venue, with 60 events a year, and will play host to musical events as part of the new Cumnock Tryst festival, organised by the leading Scottish composer James MacMillan, who grew up in the area.

Dumfries House lay empty after the death of the Marchioness of Bute in 1993.

Housekeepers were employed to keep the mansion in prime condition but until 2008, when the purchase was completed, it had never been open to the public.

First Minister Alex Salmond described the purchase, which included £5m from the Scottish Government, as the "save of the century" at the time.

The purchase involved a £20m loan from the Prince's charity, which has since been repaid.