South Africa has a long history of migration and settlement by various groups starting 3000 BC. Major kingdoms were established by the Zulu and Xhosa tribes in the 1400-1600 period. The Dutch established Cape Town in 1652 and were the first Europeans to settle in South Africa. Apartheid was introduced in 1948, legally separating racial groups. Nelson Mandela was imprisoned for 27 years for opposing apartheid before being released in 1990. South Africa's first democratic elections open to all races were held in 1994, where Mandela was elected president, marking the end of apartheid.