The short answer
Charles II was succeeded by his younger brother, James, Duke of York, who became King James II of England and Ireland and James VII of Scotland. Charles died on 6 February 1685, and James took the throne immediately.
Why a brother and not a son?
Charles II married Catherine of Braganza, a Portuguese princess, in 1662, but the marriage produced no surviving children. He had a number of illegitimate children with several mistresses, and he acknowledged many of them, but illegitimate children could not inherit the crown. Under the usual rules of succession, the next in line was his brother James.
The Exclusion Crisis
James had converted to Roman Catholicism, and by the late 1670s this alarmed many Protestants in England. Some members of Parliament tried to pass bills to exclude him from the succession. The dispute, usually called the Exclusion Crisis, helped create the first political groupings often described as Whigs, who supported exclusion, and Tories, who opposed it. Charles resisted the bills, dissolved Parliament several times and ultimately kept his brother’s right to succeed intact. In his last years he ruled without calling Parliament.
James II’s short reign
James took the throne with considerable early support, since many people preferred an orderly succession to the risk of another civil war. Soon after, he faced an uprising led by James Scott, Duke of Monmouth, one of Charles II’s illegitimate sons, who claimed the crown as a Protestant alternative. The rebellion was defeated at Sedgemoor in July 1685, and Monmouth was executed.
James’s promotion of Catholics to positions in the army and government, along with his use of royal power to set aside laws, steadily lost him support. The birth of a son in June 1688 raised the prospect of a lasting Catholic dynasty.
What came next
In late 1688 a group of English leaders invited William of Orange, who was married to James’s Protestant daughter Mary, to intervene. William landed in England in November, and James left the country in December. In 1689 Parliament offered the crown jointly to William and Mary, who reigned as William III and Mary II. This episode is known as the Glorious Revolution. The earlier return of the Stuarts is covered in our account of how Charles II restored the monarchy, and this later change shows how much the relationship between king and Parliament had shifted by the end of the century.