In 1762, Sir David Rannie purchased the estate. He had acquired a vast fortune after 30 years of trading with the East India Company in Eastern seas based on Calcutta. His return to Scotland was short-lived, as after 5 years he died, leaving his two young daughters prey to the landed gentry. The shrewd Henry Dundas, a lawyer, and son of the neighbouring estate of Arniston, was 24 when he married the 14 year old Elizabeth, acquiring both her estate and her fortune. He was clever and industrious with consuming ambition. His service as a Member of Parliament in London, under Prime Minister Pitt, was to be rewarded by an appointment as the first Viscount Melville. He also held the most prestigious and powerful position in Scotland of Lord Advocate. This is commemorated in a marble statue in the Advocates Hall in Edinburgh.
His new found wealth allowed him to commission James Playfair, the renowned Scottish architect of the time, to design a new castle and, in 1786, the old Medieval edifice was demolished and the new castle was built on its footprint. This building, an impressive castellated mansion with its spacious pillared entrance hall, elegant staircase and fine reception rooms, was created principally for entertaining on a grand scale.
In 1791, at the time of the French revolution and Britain’s war with France, Lord Melville was appointed Home Secretary and Minister for War. He now wielded enormous power throughout Britain and its dominions. His preoccupation in state matters, however, resulted in a rash investment and the loss of all of Elizabeth’s fortune in the crash of the Ayrshire Bank. This misadventure resulted in an impoverished Countess and a mortgaged Melville Castle. His successful political career, however, continued with his appointment as First Lord of the Admiralty, but these various government appointments meant that he was required to spend long months in London, whereupon his long suffering wife, her fortune lost, eloped into the arms of another.
In 1822, in anticipation of George IV’s visit to Scotland, an impressive fluted stone column 135ft high was erected in the gardens of St. Andrews Square to bear the figure of the King. However, the Edinburgh dignitaries, momentarily displeased with the King, surmounted the column with the figure of Lord Melville. The King was required to make do with a less prominent position in Hanover Street and a modest pedestal of only 15 feet. Lord Melville also had sight of the plans for the New Town and, to the dismay of the officials, he acquired the principal site in St Andrews Square and built the finest classical mansion house in the city. The church originally intended for the site had to be relocated to George Street. It is known as Saint Andrews ‘the round church which leaves no corner for the devil.’
In 1828, King George IV again visited Scotland as a guest of the Duke of Buccleuch at Dalkeith Palace. Whether aware of his displacement from St. Andrews Square, the King visited Melville Castle. For this, a special carriage way, now Melville Gate Road, was created between the two mansions. A grand review of the Midlothian Yeomanry, of which Lord Melville was Colonel, took place on the south lawn. For this occasion Lord Melville arranged a lavish banquet and among the distinguished personages gathered to meet the King was Sir Walter Scott, who lived nearby and was a frequent visitor to the castle. It is recorded that a sumptuous meal was enjoyed by the guests and the members of the Yeomanry, who were amply provided for. The estate workers also enjoyed a feast and there was still enough food remaining for the poor of the district to be fed.