Dundas entered into negotiations for the purpose of securing Lord North's support to the ministry. The latter, however, refused to commit himself, and directly afterwards formed the coalition with Fox which put an end to the Shelburne administration (ib. pp. 30–7). Dundas then attempted to prevail on Pitt to accept the office of prime minister, but after a long ministerial interregnum the coalition government came into power in April 1783, and Dundas was succeeded as treasurer of the navy by Charles Townshend. The office of lord advocate Dundas continued to hold for some time longer, but in spite of his boast that ‘no man in Scotland will venture to take my place,’ he was at length displaced by Fox in August 1783 in favour of Henry Erskine. On 14 April 1783 Dundas moved for leave to bring in his bill for the regulation of the government of India (Parl. Hist. xxiii. 757–60). As the government afterwards brought in a bill of their own. Dundas abandoned his, and vehemently denounced Fox's as ‘big with the most alarming consequences to the constitution’ (ib. 1401–3).
Upon Pitt's accession to power Dundas once more became treasurer of the navy, an office which he continued to hold until June 1800. He was also appointed one of the committee of the privy council for trade and foreign plantations on 5 March 1784, and on the passing of Pitt's East India Bill was constituted a member of the board of control on 3 Sept. in the same year. Though Dundas did not become president of the board of control until 28 June 1793, the management of Indian affairs was practically left in his hands from the first formation of the board. Towards the close of the session of 1784 Dundas brought in a bill for the restoration of the forfeited estates in Scotland, which was received with great favour in that country, and passed through both houses with little difficulty (24 Geo. III, sess. 2, c. 57). In December 1785 Dundas, who had for some years been dean of the Faculty of Advocates, resigned that office and was succeeded by Henry Erskine. When Burke brought the charge arising out of the Rohilla war against Hastings in June 1786, Dundas, in spite of the resolutions which he had himself carried in the House of Commons in 1782, opposed it. In his speech on this occasion he called Hastings ‘the saviour of India,’ and endeavoured to explain his own position by declaring that, though he still condemned the Rohilla war, what he had formerly desired was the recall, and not the criminal prosecution, of Hastings (Parl. Hist. xxvi. 87–9). A few days later the ministry suddenly changed their policy, and when Fox brought forward the charge relating to the rajah of Benares, Pitt spoke in favour of the motion and Dundas silently voted with the majority. At the general election in June 1790 Dundas was returned for the city of Edinburgh, for which constituency he continued to sit until his elevation to the peerage. In June 1791 he became home secretary, in the place of Lord Grenville, who had been appointed the secretary for foreign affairs. Dundas's appointment, which was at first merely a provisional one, was confirmed on the refusal of Lord Cornwallis, who was then in India, to accept the post.
On 23 April 1793 Dundas moved a resolution pledging the house to secure the renewal of the monopoly to the East India Company for a further term of years. He defended the government of India by the company at great length, and maintained that the country had been indebted to the company for the great increase of its shipping (ib. xxx. 660–85). His speech on this occasion was in Pitt's opinion one which, ‘for comprehensive knowledge of the history of India, and of the various sources of the British commerce to the East Indies, … though it might have been equalled in that house, had never been excelled’ (ib. 945). On the accession of the Duke of Portland to the ministry in the summer of 1794 he was appointed home secretary in the place of Dundas, who accepted the new secretaryship of war. As the duke shortly afterwards laid claim to all the rights of patronage which Dundas had hitherto possessed, the latter announced that he should resign the seals and relinquish the conduct of the war. After great pressure from Pitt, who declared that he should ‘give up all hope of carrying on the business with comfort, and be really completely heartbroken if you adhere to the resolution’ (Stanhope, Life of Pitt, ii. 53), and a letter from the king desiring him ‘to continue secretary of state for the war,’ Dundas consented to remain in office. On 10 June 1800 he was appointed keeper of the privy seal of Scotland. The credit of the Egyptian campaign of 1801 was in a great measure due to his energy and perseverance, as he both planned and carried out the expedition against the opinion of Pitt and the king. With reference to this campaign it is related that Dundas used afterwards to tell with pride how on one occasion the king proposed a toast ‘to the minister who planned the expedition to Egypt, and in doing so had the courage to oppose his king.’ On Pitt's resignation in March 1801 Dundas resigned the office of secretary for war, and in the following May resigned his