In 1589 James sailed to Denmark to collect his bride, Anne, and the return voyage met storms severe enough that the fleet had to shelter in Norway. Danish officials blamed witchcraft, and the accusation crossed to Scotland. The North Berwick trials that followed, running from 1590 into 1591, produced confessions under torture that a coven had met in the kirkyard at North Berwick, sent a familiar to sea to raise the storms, and worked to kill the king because he was the greatest enemy the devil had in the world. James attended examinations in person and questioned suspects himself.
Out of that experience came Daemonologie, printed at Edinburgh in 1597. It is a short dialogue in three books arguing that witchcraft is real, that scripture and reason both establish it, that magistrates have a duty to punish it, and, against the sceptics he names, that denying its existence is itself an error. It distinguishes necromancy from witchcraft, discusses spirits and possession, and argues for the death penalty. Coming from a reigning monarch, it carried a weight no clerical treatise could.
The consequences were legal and cultural. Scotland saw one of the most intense witch prosecutions in Europe over the following century, and in England the first parliament of James's reign passed the Witchcraft Act of 1604, which made invoking spirits a capital felony without benefit of clergy and which remained in force until 1736. Shakespeare, writing Macbeth for a company under royal patronage, drew on the demonology his new king had published, and the play's Scottish setting and its weird sisters are usually read as an address to that interest. Historians have noted that James's own scepticism grew in later life, and he exposed several fraudulent accusations personally.