Malcolm II was the last king of Scotland to be elected by the method of tanistry, by which an heir to the throne was selected during a monarch's lifetime. He was the son of Kenneth II (born c.958) and first cousin to his predecessor, Kenneth III. He was also the last king of the House of Alpin, as he had no sons to succeed him.
He came to the throne in 1005, after killing Kenneth III in battle. A year later he fought the English at Durham, was defeated, but retained the kingdom and, in 1018, while the English were preoccupied with Danish raiders, he marched south, won the battle of Carham, and secured Scotland's rights to Lothian. The battle of Carham appears to have been the seed that established the River Tweed as the traditional Anglo-Scottish border.
He was later "invaded" by Canute the Great, who, it appears, may have taken Malcolm's homage, but left his kingdom otherwise unaffected, and have ratified the transfer of Lothian to Scots hands.
He married his daughter to the Norse Earl of Orkney, Sigurd the Stout, and allied himself with Owen the Bald, king of Strathclyde, but his attempt to annexe Strathclyde after Owen's death led to dissent and to Malcolm's death in 1034 at Glamis. On the other hand, on Sigurd's death, Malcolm was able to get his own grandson, Thorfinn, accepted as earl of Caithness (even though he was only 5), and little by little the lad acquired the remainder of the Orkney lands.
His other daughter, Bethoc, had married Crinan, the lay Abbot of Dunkeld, and their son, Duncan succeeded to the throne, as first king of the House of Atholl.
There are indications, given that other men, contemporary to Malcolm, are described as "king of Alba" (the older name for Scotland), that he may not have reigned over all of modern Scotland, but may have been restricted to a central band, between northern claimants and challengers, and the English (especially the earls of Northumbria) to the south.
Equally the claim that he married a daughter of the Irish king Brian Boru appears unsubstantiated. Another version has him marrying a daughter (Agatha) of Sigurd of Orkney, to whom Malcolm would later marry his own daughter. However, this appears impossible, since Agatha would need to have been born before her father.