James VII of Scotland
When Charles II died in 1685 he was succeeded by his brother, James VII. James, a Catholic, made it illegal to support the Covenant, and he treated dissenters harshly. However, in a quick about-face, he then passed a new law allowing Presbyterians to leave the bishop-led Church of Scotland. He also granted freedom of worship to Catholics.
Now, James was ousted in England in favour of the staunchly Protestant William and Mary of Orange. The circumstances of the transfer of power were a matter of some confusion in Scotland. The Scottish Parliament did not at first offer the crown to William and Mary. Some Scots believed that James VII had abdicated, others that he had merely been forced into exile but still deserved to be considered the king of Scotland.
At a Convention of Estates in Edinburgh, the Scots gathered to choose between William and James. William promised to support Protestantism, while James blustered and threatened. As public relations efforts go, it was a dead-loss for James, and the Convention chose to offer the crown to William, on condition that he accept the Convention's terms, which included guarantees protecting the Church of Scotland, removal of the bishops, and putting the church under the control of Parliament, not the king.
The divisions caused by the removal of James VII split Scottish society between Williamites (who believed that William was now the legal king), and Jacobites (who believed that James Stuart was still king). The term Jacobite comes from the Latin 'Jacobus', for James. Not all Scottish Jacobites were Catholic; some merely thought that James had the better claim to be king.
The Battle of Killiecrankie
One of the first Jacobites was John Graham, Viscount Dundee, sometimes called 'Bonnie Dundee'. Dundee raised an army of Jacobite sympathizers, mainly from the Highland clans, and marched on Perth. He was met by a larger English army at Killiecrankie. However, the Highlanders used the narrow pass to their advantage and decimated the English troops. However, Dundee was killed and after some fairly pointless looting, the Highlanders dispersed.