Year 840 (DCCCXL) was a leap year starting on Thursday (link will display the full calendar) of the Julian calendar.
June 20 – Emperor Louis the Pious falls ill and dies at his hunting lodge, on an island in the Rhine, near his imperial palace at Ingelheim, while suppressing a revolt. His eldest son Lothair I succeeds him as Holy Roman Emperor, and tries to seize all the territories of the late Charlemagne. The 17-year-old Charles the Bald becomes king of the Franks, and joins the fight with his half-brother Louis the German in resisting Lothair.
King Wigstan of Mercia, grandson of former ruler Wiglaf (see 839), declines his kingship and prefers the religious life. He asks his widowed mother, Princess Ælfflæd, to act as regent. A nobleman of the line of the late king Beornred, named Berhtric, wishes to marry her but he is a relative. Wigstan refuses the match, and is murdered by followers of Berhtric at Wistow. He is buried at Repton Abbey, and later revered as a saint. The Mercian throne is seized by Berhtric's father, Beorhtwulf.
Vikings make permanent settlements with their first 'wintering over', located at Lough Neagh in Northern Ireland (approximate date).
Emperor Wen Zong (Li Ang) dies after a 13-year reign, in which he has failed to break the power of his palace eunuchs. He is succeeded by his brother Wu Zong, as Chinese ruler of the Tang Dynasty.
The Yenisei Kirghiz settle along the Yenisei River, and sack with a force of around 80,000 horsemen the Uyghur capital, Ordu-Baliq (driving the Uyghurs out of Mongolia). This ends the Uyghur Khaganate.
Nobis becomes bishop of St. David's, in the Welsh Kingdom of Dyfed (approximate date).
January 19 – Michael III, Byzantine emperor (d. 867)
Abu al-Hassan al-Nuri, Muslim sufi (approximate date)
Adalhard II, Frankish nobleman (approximate date)
Berengaudus, Benedictine monk (d. 892)
Clement of Ohrid, Bulgarian scholar (approximate date)
Eudokia Ingerina, Byzantine empress (approximate date)
Hucbald, Frankish music theorist (or 850)
Lothar I, Frankish nobleman (d. 880)
Notker the Stammerer, Benedictine monk (approximate date)
Richardis, Frankish empress (approximate date)
Sunyer II, Frankish nobleman (approximate date)
Theodard, archbishop of Narbonne (approximate date)
Theodore II, pope of the Catholic Church (d. 897)
Unruoch III, margrave of Friuli (approximate date)
Ya'qub ibn al-Layth, founder of the Saffarid Dynasty (d. 879)
March 14 – Einhard, Frankish scholar
June 11 – Junna, emperor of Japan (b. 785)
June 16 or 839 – Rorgon I, Frankish nobleman
June 20 – Louis the Pious, king of the Franks (b. 778)
Agobard, archbishop of Lyon (b. 779)
Andrew II, duke of Naples
Ansovinus, archbishop of Camerino
Czimislav, king of the Sorbs (approximate date)
He Jintao, general of the Tang Dynasty
Hilduin, archbishop of Paris (b. 775)
Li Chengmei, prince of the Tang Dynasty
Li Rong, prince of the Tang Dynasty
Muhammad at-Taqi, Muslim ninth Ismā'īlī imam (or 839)
Salmawaih ibn Bunan, Muslim physician
Wen Zong, emperor of the Tang Dynasty (b. 809)
Wigstan, king of Mercia (approximate date)
Yang, consort and concubine of Wen Zong
840 Wikipedia (Text) CC BY-SA