The original inhabitants of the area now known as Lesotho were the San people. Examples of their rock art can be found in the mountains throughout the area.
The present Lesotho, then called Basutoland, emerged as a single polity under King Moshoeshoe I in 1822. Moshoeshoe, a son of Mokhachane, a minor chief of the Bakoteli lineage, formed his own clan and became a chief around 1804. Between 1821 and 1823, he and his followers settled at the Butha-Buthe Mountain, joining with former adversaries in resistance against the Lifaqane associated with the reign of Shaka Zulu from 1818 to 1828.
Subsequent evolution of the state hinged on conflicts between British and Dutch colonists leaving the Cape Colony following its seizure from the French-allied Dutch by the British in 1795, and subsequently associated with the Orange River Sovereignty and subsequent Orange Free State. Missionaries invited by Moshoeshoe I, Thomas Arbousset, Eugène Casalis and Constant Gosselin from the Paris Evangelical Missionary Society, placed at Morija, developed orthography and printed works in the Sesotho language between 1837 and 1855. Casalis, acting as translator and providing advice on foreign affairs, helped to set up diplomatic channels and acquire guns for use against the encroaching Europeans and the Griqua people.
Trekboers from the Cape Colony showed up on the western borders of Basutoland and claimed land rights, beginning with Jan de Winnaar, who settled in the Matlakeng area in May–June 1838. As more Boers were moving into the area they tried to colonise the land between the two rivers, even north of the Caledon, claiming that it had been abandoned by the Sotho people. Moshoeshoe subsequently signed a treaty with the British Governor of the Cape Colony, Sir George Thomas Napier, that annexed the Orange River Sovereignty that many Boers had settled. These outraged Boers were suppressed in a brief skirmish in 1848. In 1851 a British force was defeated by the Basotho army at Kolonyama, touching off an embarrassing war for the British. After repelling another British attack in 1852, Moshoeshoe sent an appeal to the British commander that settled the dispute diplomatically, then defeated the Batlokoa in 1853.
In 1854 the British pulled out of the region, and in 1858 Moshoeshoe fought a series of wars with the Boers in the Free State–Basotho War, losing a great portion of the western lowlands. The last war in 1867 ended when Moshoeshoe appealed to Queen Victoria, who agreed to make Basutoland a British protectorate in 1868. In 1869, the British signed a treaty at Aliwal North with the Boers that defined the boundaries of Basutoland, and later Lesotho, which by ceding the western territories effectively reduced Moshoeshoe's Kingdom to half its previous size.
Following the cession in 1869, the British initially transferred functions from Moshoeshoe's capital in Thaba Bosiu to a police camp on the northwest border, Maseru, until administration of Basutoland was transferred to the Cape Colony in 1871. Moshoeshoe died on 11 March 1870, marking the end of the traditional era and the beginning of the colonial era. He was buried at Thaba Bosiu. In the early years of British rule between 1871 and 1884, Basutoland was treated similarly to other territories that had been forcefully annexed, much to the chagrin of the Basotho. This led to the Gun War in 1881. In 1884, Basutoland was restored its status as a protectorate, with Maseru again its capital, but remained under direct rule by a governor, though effective internal power was wielded by traditional chiefs.
Basutoland gained its independence from Britain and became the Kingdom of Lesotho in 1966.
In January 1970, the ruling Basotho National Party (BNP) lost the first post-independence general elections, with 23 seats to the Basutoland Congress Party's 36. Prime Minister Leabua Jonathan refused to cede power to the Basotho Congress Party (BCP), declared himself Tona Kholo (Sesotho translation of prime minister), and imprisoned the BCP leadership.
BCP began a rebellion and then received training in Libya for its Lesotho Liberation Army (LLA) under the pretense of being Azanian People's Liberation Army (APLA) soldiers of the Pan Africanist Congress (PAC). Deprived of arms and supplies by the Sibeko faction of the PAC in 1978, the 178-strong LLA was rescued from their Tanzanian base by the financial assistance of a Maoist PAC officer, but they launched the guerrilla war with only a handful of old weapons. The main force was defeated in northern Lesotho, and later guerrillas launched sporadic but usually ineffectual attacks. The campaign was severely compromised when BCP's leader, Ntsu Mokhehle, went to Pretoria. In the early 1980s, several Basotho who sympathised with the exiled BCP were threatened with death and attacked by the government of Leabua Jonathan. In September 1981, the family of Benjamin Masilo was attacked. A few days later, Edgar Mahlomola Motuba was taken from his home and murdered.
The BNP ruled from 1966 till January 1970. What later ensued was a de facto government led by Dr Leabua Jonathan until 1986 when a military coup forced it out of office. The Transitional Military Council that came to power granted executive powers to King Moshoeshoe II, who was until then a ceremonial monarch. But in 1987 the King was forced into exile after coming up with a six-page memorandum on how he wanted the Lesotho's constitution to be, which would have given him more executive powers had the military government agreed. His son was installed as King Letsie III.
The chairman of the military junta, Major General Justin Metsing Lekhanya, was ousted in 1991 and replaced by Major General Elias Phisoana Ramaema, who handed over power to a democratically elected government of the BCP in 1993. Moshoeshoe II returned from exile in 1992 as an ordinary citizen. After the return to democratic government, King Letsie III tried unsuccessfully to persuade the BCP government to reinstate his father (Moshoeshoe II) as head of state.
In August 1994, Letsie III staged a military-backed coup that deposed the BCP government, after the BCP government refused to reinstate his father, Moshoeshoe II, according to Lesotho's constitution. The new government did not receive full international recognition. Member states of the Southern African Development Community (SADC) engaged in negotiations to reinstate the BCP government. One of the conditions Letsie III put forward for this was that his father should be re-installed as head of state. After protracted negotiations, the BCP government was reinstated and Letsie III abdicated in favour of his father in 1995, but he ascended the throne again when Moshoeshoe II died at the age of fifty-seven in a supposed road accident, when his car plunged off a mountain road during the early hours of 15 January 1996. According to a government statement, Moshoeshoe had set out at 1 am to visit his cattle at Matsieng and was returning to Maseru through the Maluti Mountains when his car left the road.
In 1997, the ruling BCP split over leadership disputes. Prime Minister Ntsu Mokhehle formed a new party, the Lesotho Congress for Democracy (LCD), and was followed by a majority of members of parliament, which enabled him to form a new government. Pakalitha Mosisili succeeded Mokhehle as party leader and the LCD won the general elections in 1998. Although the elections were pronounced free and fair by local and international observers and a subsequent special commission appointed by SADC, the opposition political parties rejected the results.
Opposition protests in the country intensified, culminating in a peaceful demonstration outside the royal palace in August 1998. Exact details of what followed are greatly disputed, both in Lesotho and South Africa. While the Botswana Defence Force troops were welcomed, tensions with South African National Defence Force troops were high, resulting in fighting. Incidences of sporadic rioting intensified when South African troops hoisted a South African flag over the Royal Palace. By the time the SADC forces withdrew in May 1999, much of the capital of Maseru lay in ruins, and the southern provincial capital towns of Mafeteng and Mohale's Hoek had seen the loss of over a third of their commercial real estate. A number of South Africans and Basotho also died in the fighting.
An Interim Political Authority (IPA), charged with reviewing the electoral structure in the country, was created in December 1998. The IPA devised a proportional electoral system to ensure that the opposition would be represented in the National Assembly. The new system retained the existing 80 elected Assembly seats, but added 40 seats to be filled on a proportional basis. Elections were held under this new system in May 2002, and the LCD won again, gaining 54% of the vote. But for the first time, opposition political parties won significant numbers of seats, and despite some irregularities and threats of violence from Major General Lekhanya, Lesotho experienced its first peaceful election. Nine opposition parties now hold all 40 of the proportional seats, with the BNP having the largest share (21). The LCD has 79 of the 80 constituency-based seats. Although its elected members participate in the National Assembly, the BNP has launched several legal challenges to the elections, including a recount; none has been successful.
On 30 August 2014, an abortive military coup took place forcing the current Prime Minister to briefly flee to South Africa.