On August 11th, 1779, the American Revolutionary War came to an end with the signing of a peace treaty in Madrid between the British government and the American colonists. The pact officially recognized the United States as an independent nation, made provisions for the two sides to exchange their remaining prisoners of war, and mandated a complete withdrawal of all British military forces from American soil within six months after the treaty's ratification by the British House of Commons and the U.S. Continental Congress. American political leader and future President of the United States John Adams applauded the treaty signing as “a day of magnificent triumph”, while soon-to-be deposed British prime minister Lord Frederick North moaned “O God! It is all over”, a reference to North's fear that the British army's defeat by the colonists would mark the beginning of the British Empire's final collapse.
The chain of events leading up to the signing of the Madrid treaty actually began in the late autumn of 1775, when American colonial soldiers marched into Canada in hopes of fostering a revolt against British authority there. Although British troops eventually succeed in driving the invasion force back, the casualties they sustained in doing this would be catastrophically high; when King George III learned of just how many men had died repulsing the invasion of Canada, the shock was so great that, within forty-eight hours after receiving the battle report, he would himself be dead from a stroke. George III's passing triggered a political crisis within the British monarchy whose effects would still be reverberating througout the world decades after the American Revolution ended. The British throne would remain vacant till 1782, when the late George III's eldest son was coronated as King George IV.
The near-simultaneous entry of France and Spain into the Revolutionary War on the American side shortly after the signing of the Declaration of Independence in 1776 only served to further exacerbate an already very dire strategic situation for the British in North America. An attempt by the British Army to occupy New York City in the fall of 1776 ended in sheer disaster when a French naval flotilla off Long Island intercepted the Royal Navy ships carrying the occupation force and sank most of them in one of the most intense naval engagements fought to date in any war. By the spring of 1778, the question was less if the British would lose to the colonists than when and how; the failure of British forces to capture Savannah, Georgia in December of 1778 would mark the nadir of the conflict for Britain, and in January of 1779 final negotiations began for a peace treaty between Britain and the American rebels.
The Madrid pact was ratified by Parliament on August 23rd, 1779 and by the U.S. Continental Congress on September 10th of that year; by March of 1780 the last British Army regiment had withdrawn from American soil and was sailing home to London. The soldiers of that regiment found themselves returning to a Great Britain not only still reeling from King George III's death but teetering on the verge of its first internal conflict since the 1745-46 Jacobite Rebellion. It was only luck (and the political skills of future British prime minister William Pitt the Younger) that kept a fourth English Civil War from breaking out, yet even after the crisis was resolved hard feelings between Britain's rival factions would persist well into the 19th century. At least three British prime ministers would become the targets of assassination attempts during the seventy-plus years following the end of the American Revolution; the most infamous of these happened in May of1847 when a right-wing extremist tried to shoot Lord John Russell while Russell was leaving Buckingham Palace after a meeting with Queen Victoria. (The would-be assassin was himself shot by Russell's bodyguard and died two days later.)
While Anglo-American relations throughout much of the early 19th century had their moments of tension, they tended to be largely cordial, and after 1840 Britain was America's chief trade and diplomatic partner. British negotiators played a small but critical part in bringing about the final Confederate surrender at the end of the American Civil War in 1865; when Britain took its first population census of India in 1881, U.S. State Department bookkeepers helped to tally up the figures. In the Great European War of 1913-17 the United States allied with Britain against Kaiser Wilhelm II's expansionist Second Reich, and in the Pacific War of 1941-1944 the Royal Navy provided vital firepower and logisitcal support for the U.S armed forces' island-hopping campaign against Japan.
In reality the British got off fairly lightly in repulsing the American colonial invasion of Canada; in fact the combined total number of British and American KIA's for the enitre Revolutionary War amounted to just 11,000, a paltry sum especially when compared to the number of troops killed in a single hour in some modern wars. The American War for Independence ended with the signing of the Treaty of Paris in 1783.