His first wife was Joan or Joanna, daughter of the English king Edward II and of Isabella of France (although by the time of the marriage Edward had been deposed, and the marriage was the fruit of Isabella's attempt (supported by her lover Mortimer) to secure the peace with Scotland). He married her in 1328, when he was 4, but this marriage alliance did not prevent his father-in-law from supporting the English usurper Edward Balliol. David was crowned and anointed king in 1331, but by 1333 Balliol, backed by English armies, had advanced far enough for David and his Queen to be sent to France for safety.
There they were made welcome by Philip VI and housed in Richard I's Chateau-Gaillard. In Scotland Balliol squandered what little goodwill he had attracted and by 1341 David was back in Scotland. In 1346, in alliance with France, David invaded England, was defeated and taken prisoner, and spent 11 years in English imprisonment, until in 1357, for 100,000 marks he was ransomed. In fact Scotland was far too poor to pay but it is possible that Edward III's longer-term plan was to seize the kingdom for failure to pay the debt. David, however, successfully distracted him by suggesting he could make Edward or one of his sons the successor to Scotland's throne (a proposal which would never have met with assent among the Scots nobility).
Joan died in 1361-2 and, widowed, David married Margaret, daughter of Malcolm Drummond and widow of Sir John Logie, from whom he was divorced in 1369-70. He had children by neither wife, and had had insufficient time to marry Agnes Dunbar, his mistress. This meant that the Scots succession passed from the House of Bruce, via his sister Marjorie to her husband, Walter, the 6th High Steward of Scotland, thus founding the House of the Stewards, or the Stuarts as they became.
On one hand, David lost almost everything that his father had gained for Scotland; on the other he had to cope with English kings determined to plough Scotland under, and managed to retain his country's independence, despite being first unseated, and then imprisoned.