James IV of Scotland is defeated and dies in the Battle of Flodden, ending Scotland's involvement in the War of the League of Cambrai.

The Battle of Flodden, Flodden Field, or occasionally Branxton, (Brainston Moor) was a battle fought on 9 September 1513 during the War of the League of Cambrai between the Kingdom of England and the Kingdom of Scotland, resulting in an English victory. The battle was fought near Branxton in the county of Northumberland in northern England, between an invading Scots army under King James IV and an English army commanded by the Earl of Surrey. In terms of troop numbers, it was the largest battle fought between the two kingdoms.After besieging and capturing several English border castles, James encamped his invading army on a commanding hilltop position at Flodden and awaited the English force which had been sent against him, declining a challenge to fight in an open field. Surrey's army therefore carried out a circuitous march to position themselves in the rear of the Scottish camp. The Scots countered this by abandoning their camp and occupying the adjacent Branxton Hill, denying it to the English. The battle began with an artillery duel followed by a downhill advance by Scottish infantry armed with pikes. Unknown to the Scots, an area of marshy land lay in their path, which had the effect of breaking up their formations. This gave the English troops the chance to bring about a close-quarter battle, for which they were better equipped. James IV was killed in the fighting, becoming the last monarch from Great Britain to die in battle; this and the loss of a large proportion of the nobility led to a political crisis in Scotland. British historians sometimes use the Battle of Flodden to mark the end of the Middle Ages in the British Isles; another candidate is the Battle of Bosworth Field in 1485.

James IV (17 March 1473 – 9 September 1513) was King of Scotland from 11 June 1488 until his death at the Battle of Flodden in 1513. He inherited the throne at the age of fifteen on the death of his father, James III, at the Battle of Sauchieburn, following a rebellion in which the younger James was the figurehead of the rebels. James IV is generally regarded as the most successful of the Stewart monarchs. He was responsible for a major expansion of the Scottish royal navy, which included the founding of two royal dockyards and the acquisition or construction of 38 ships, including the Michael, the largest warship of its time.James was a patron of the arts and took an active interest in the law, literature and science, even personally experimenting in dentistry and bloodletting. With his patronage the printing press came to Scotland, and the Royal College of Surgeons of Edinburgh and the University of Aberdeen were founded. He commissioned the building of Holyrood Palace and Falkland Palace, and extensive building work at Linlithgow Palace, Edinburgh Castle and Stirling Castle. The education act passed by the Parliament of Scotland in 1496 introduced compulsory schooling.

During James's 25 year reign, royal income doubled, the crown exercised firm control over the Scottish church, royal administration was extended to the Highlands and the Hebrides, and by 1493 James had overcome the last independent Lord of the Isles. Relations with England were improved with the Treaty of Perpetual Peace in 1502 and James's marriage to Margaret Tudor in 1503 (the marriage led to the Union of the Crowns in 1603, when Elizabeth I of England died without heirs and James IV's great-grandson James VI succeeded to the English throne). The long period of domestic peace after 1497 allowed James to focus more on foreign policy, which included the sending of several of his warships to aid his uncle, King John of Denmark, in his conflict with Sweden; amicable relations with the Pope, Holy Roman Emperor Maximilian I and Louis XII of France; and James's aspiration to lead a European naval crusade against the Turks of the Ottoman Empire. James was granted the title of Protector and Defender of the Christian Faith in 1507 by Pope Julius II.

When Henry VIII of England invaded France in 1513 as part of the Holy League, James chose the Auld Alliance with the French over the 'Perpetual Peace' with the English, and answered France's call for assistance by leading a large army across the border into England. James and many of his nobles were killed at the Battle of Flodden on 9 September 1513. He was the last monarch in Great Britain to be killed in battle, and was succeeded by his son James V.