Regency
By April 1398, Robert III's rule of Scotland was facing severe criticism in many parts of the kingdom. The king, who suffered from periodic bouts of illness, was accused of failing to maintain order in northern Scotland. At the time of his creation as Duke of Rothesay that same month, David was tasked by the general council with leading an army into the Highlands to confront Donald, Lord of the Isles, who had recently raided in Moray. David's uncle, Robert, who had been created Duke of Albany on the same day as David's own elevation to ducal status, was appointed as joint leader of the expedition against Donald. The royal campaign in the north was derailed when Walter Danielston, a brother of the former castellan of Dumbarton Castle, seized control of the castle against Robert III's wishes. Although he laid siege to Dumbarton with a large army in late 1398, Robert III was unable to remove Danielston from the castle. David joined his father at the siege of Dumbarton, where he was given the earldom of Atholl in September 1398, possibly as a reward for his efforts to pacify northern Scotland. Robert III's failure to recapture Dumbarton was the final blow to his prestige and political authority. David attended a gathering of noblemen at Falkland Palace, the residence of his uncle Robert, Duke of Albany, in November 1398, where the two men likely decided to remove the king from power.
At a general council held at Perth in January 1399, Robert III was forced to surrender power to David as regent of the kingdom. The king's subjects were ordered to obey and support David "as they should do with the king's person". He was officially styled as "lieutenant" for his father. David's assumption of power was supported by Archibald, 3rd Earl of Douglas, in the prelude to David's marriage to the earl's daughter the following year. David was also supported by his mother Annabella, who had arranged for him to be knighted at a tournament in Edinburgh. At the beginning of his regency, David cooperated with his uncle, the Duke of Albany, in the governance of Scotland. The parliamentary statutes that had allowed David to assume power also required him to take advice from a council of twenty-one noblemen and prelates, including Robert, Duke of Albany, and Walter Stewart of Brechin, another of David's uncles. David's maternal uncle, Malcolm Drummond, reconciled with the Duke of Albany in 1399, likely as part of a general rapprochement between the affinities of David and Robert.
David convened a parliament at Scone in February 1401, where he was responsible for new statutes of criminal and property law. One of the decrees of this parliament was that widows and orphans should have greater access to David and other royal officials, a measure intended to allow poor petitioners to complain to the king's council more easily. David also issued statutes on hunting and the burning of moorland.
After the deposition of Richard II of England in 1399, David seems to have authorized Scottish raids into northern England. Shortly before the coronation of the new English king, Henry IV, on 13 October 1399, a Scottish army destroyed Wark Castle in Northumberland.
George, Earl of March, appealed to Henry IV for support in the spring of 1400, after David had repudiated the earl's daughter, Elizabeth, to marry Mary Douglas. Henry responded to these appeals by invading Scotland in August 1400, raising an army of 20,000 men for the purpose. The English army advanced to Leith, where Henry demanded the feudal homage of Robert III and the Scottish nobility. Upon hearing of Henry's approach, David retreated to Edinburgh Castle, where he barricaded himself alongside his brother-in-law, Archibald, Master of Douglas, and other noblemen. David responded to Henry's demands for homage in a defiant letter, in which he refused to accord Henry the title of King of England, and offered a staged battle between members of the English and Scottish nobility as a means to end the war. According to the contemporary author Walter Bower, David clashed with his uncle, Robert, Duke of Albany, over the conduct of the war, with the duke refusing to bring his army to David's aid at Edinburgh. Henry was unable to defeat the Scots in a pitched battle and, lacking the supplies to besiege Edinburgh Castle, withdrew to England in September.
In March 1401, David and his uncle, the Duke of Albany, attempted to open negotiations with Henry IV for peace, but were prevented from doing so by David's brother-in-law Archibald, who had now become Earl of Douglas. Archibald physically prevented David from entering the West March. Around this time, Henry Percy led an English army to raid in East Lothian, but was defeated by Archibald. David arranged negotiations with English representatives at Kirk Yetholm in October 1401, but probably fell from power before they could take place.