The history of Botswana encompasses the region's ancient and tribal history, its colonisation as the Bechuanaland Protectorate, and the present-day Republic of Botswana. The first modern humans to inhabit Botswana were the San people, and agriculture first developed approximately 2,300 years ago. The first Bantu peoples arrived , and the first Tswana people arrived about 200 years later. The Tswana people split into various tribes over the following thousand years as migrations within the region continued, culminating in the Difaqane in the late 18th century. European contact first occurred in 1816, which led to the Christianization of the region.

Facing threats from German South West Africa and the Afrikaners, the most influential Tswana chiefs negotiated the creation of a protectorate under the United Kingdom in 1885. The British divided the territory into tribal reserves for each of the major chiefs to rule, giving the chiefs more power than they had previously, but it otherwise exercised only limited direct control over the protectorate. The British government took a more active role beginning in the 1930s. Botswana supported British involvement in World War II and many fought as part of the African Auxiliary Pioneer Corps.

A power struggle took place in the 1950s between the Ngwato chief Seretse Khama and his regent Tshekedi Khama. Seretse's marriage to a white woman, Ruth Williams Khama, led the British to ban him from the protectorate. He returned in 1956 with popular support, and tribes moved toward elected government as an independence movement formed. A national legislature was created in 1961, and political parties were formed. Seretse became the leader of the Bechuanaland Democratic Party, which was endorsed by the British government to lead post-independence, and it saw overwhelming support in the first election in 1965. The Republic of Botswana was granted full independence in 1966.

With a strong mandate, Seretse and his party implemented liberal democracy and began developing infrastructure in what was one of the world's poorest nations. Extensive diamond deposits were discovered in 1969, causing a massive reorganisation of Botswana's economy. The Debswana mining company was created in 1978, and Botswana became the world's fastest growing economy. The HIV/AIDS pandemic became a crisis in Botswana in the 1980s, and the 1990s came with the introduction of political factionalism after the political scandal of the Kgabo Commission. The Botswana Democratic Party remained the dominant party from independence until the Umbrella for Democratic Change won the 2024 general election.

Pre-colonial history Prehistory and early history

Present-day Botswana was primarily forest ten million years ago, and the rivers were much larger than they are in the present, flowing into a massive paleolake, Lake Makgadikgadi. Homo erectus lived in the region during the Early Stone Age. Stone tools in present-day Botswana, such as Acheulean axes, date back to two million years ago. Hominin migration to the Kalahari Desert is estimated to have happened prior to Marine Isotope Stage 6, 186,000 years ago. Lake Makgadikgadi began to shrink approximately 50,000 years ago.

The ancestors of the Khoe and San peoples—unrelated peoples who are referred to collectively as the Khoisan or Sarwa peoples—lived in present-day Botswana by approximately 40,000 to 30,000 years ago. They may have been the first humans to enter the Late Stone Age. They established themselves around rivers during drier periods of history but spread throughout the region during wetter periods. They are known to have inhabited the areas around Lake Makgadikgadi, as well as Tsodilo and ≠Gi. Other peoples such as the Nata, Shua, and Xani are believed to have arrived after the Khoe and San. Rock art dates back to approximately 30,000 years ago, Mining of specularite and hematite began around this time to create paints. Virtually all permanent bodies of water were associated with early human populations by 20,000 years ago. More detailed study of southern Africa in the Stone Age has been limited.

The various peoples of the region were hunter-gatherers who remained in small groups and engaged in trade with one another. It is believed that each group was a collection of related families holding a specific territory, led by the eldest man of the group's head family. Men hunted large animals, while women gathered plants and caught small animals. The groups intermarried and practiced a dowry system, xaro.

Approximately 2,000 years ago, the peoples of the region brought cattle and sheep to present-day Botswana and began making pottery. Agriculture developed during this time and the peoples began settling in villages, which rose and fell as the climate and cattle raids caused livestock access to fluctuate. Among the earliest crops were pearl millet, finger millet, sorghum, Bambara groundnuts, cowpeas, and cucurbits.

The first Bantu people migrated to the region between 2,000 and 1,500 years ago, and it was once believed that they were the ones who had first introduced livestock to the area. The Kalanga people were the first of the Bantu peoples to settle in present-day Botswana, arriving . The ancestors of the first Tswana people (singular Motswana, plural Batswana) are estimated to have arrived c. 400 CE. These Bantu peoples brought iron and copper tools to the region and settled along permanent waterways. They built permanent settlements of about 10–15 pole-and-daga houses each, rather than the temporary structures of the more nomadic Khoisan. The Khoisan and the Bantu likely traded and intermarried during this period.

7th century through 14th century A group of Zhizo people, the Taukome people, arrived in present-day Botswana by the 7th century and settled between the Shashe River and the Serorome River. Their possession of glass beads indicates early connection to Indian Ocean trade. The number of livestock kept in present-day Botswana increased significantly between the 8th century and the 10th century. The Tswana people organised themselves into a type of tribal government, called a morafe (plural merafe), each led by a chief called a kgosi (plural dikgosi). This system produced a more hierarchical government relative to others in the region. Cattle became a central part of society in the region, and ownership of cattle denoted one's status. The early history of the Tswana people remains largely unknown because little archaeological evidence has been left.

Trade routes connected tribes throughout the Kalahari Desert by 900 CE, and a series of routes were created across the entire region over the following century, culminating at the Indian Ocean. Some of the Eiland people migrated from present-day South Africa into present-day Botswana in the mid-10th century. The Toutswe people, another of the Zhizo people, migrated to present-day Botswana during the 11th century and became the strongest group in the region, deriving their wealth from ownership of cattle. Three Toutswe villages were constructed at Bosutswe, Sung, and Toutswemogala, each ruling over smaller villages surrounding them. By the 12th century, the Toutswe had spread to the Kalahari Desert.

The value of products fluctuated as expanding trade with foreign nations and the discovery of gold occurred, reducing interest in specularite and animal products like ivory. One tribe in Tsodilo was particularly influential in the trade of specularite until it fell at the end of the 12th century. The tribes in southeastern Botswana were far removed from these developments and remained largely unaffected.

Neighbouring present-day Botswana during the 11th and 12th centuries were the people of Leopard's Kopje to the east. First established in Bambandyanalo, they became major figures in regional trade and moved to Mapungubwe by the late-11th century where they formed the Kingdom of Mapungubwe. They projected influence across the region through the 12th century. The peoples of the Okavango Delta and later the peoples of the Tsodilo Hills were forced to abandon their settlements during this time, which may have been because they were cut off from major trade routes. Only the Khoe people stayed in the area. Mapungubwe fell by the 13th century, and the Toutswe villages, cut off from trade, fell around the same time. The Mambo people lived around present-day Francistown and became influential around this time. The modern Tswana, Khalagari, and Sotho peoples began to form in Transvaal around the 12th century. The Khalagari migrated west to what is now southeastern Botswana. The Fokeng people also appeared to the west in the 12th century, and the Moloko people appeared by the 13th century. The original Tswana tribe, the Phofu dynasty, was created in Transvaal in the 13th century by Mogale. Over the following centuries, it split into several Tswana peoples, including the Hurutshe, Kwena, Ngwaketse, Ngwato, Tlharo, and Kgatla peoples.

The Kingdom of Zimbabwe emerged and replaced Mapungubwe as the regional power in the 13th century when the Gumanye people gained influence in the city of Great Zimbabwe, which was able to control trade more closely with its valuable land and resources and its closer proximity to the coast. Zimbabwe controlled many of the tribes that existed in what is now northeastern Botswana, and the gold trade became a driving factor in the region's economy. Zimbabwe was losing influence by the end of the 14th century, and it fell in the mid-15th century. Several other states developed after its fall. The Kingdom of Butua, formed by the Kalanga peoples, took Zimbabwe's place on the present-day Botswana–Zimbabwe border.

The Tswana and Pedi peoples followed the Khalagari people west around the late 14th century, and the Rolong people separated under the rule of Morolong. The chief Masilo is said to have ruled all of the western Tswana peoples at this time, until the Tlharo people separated from his domain. The area is then said to have been ruled by Malope at the end of the 15th century.

15th century through 18th century

Tswana peoples migrated internally through present-day Botswana as they were displaced by native and colonial populations from the south, and they had a presence throughout present-day Botswana by 1600. The original Tswana tribe, the Phofu dynasty, declined in the late-15th century. Large migrations of Kalanga and Sotho–Tswana peoples took place in the 15th and 16th centuries. The Kalanga peoples controlled the land between the Motloutse River and the Makgadikgadi Pan until the 18th century. The Hurutshe, Kgatla, and Kwena peoples split from the Phofu dynasty in the Transvaal region amid drought and hereditary conflicts, eventually migrating north to present-day Botswana. The Ngwaketse and Ngwato peoples in turn split from the Kwena around 1530. Some peoples of the region remained in the Late Stone Age until around the 16th century.