Nyerere led Tanganyika to independence from the United Kingdom in 1961. He became the new country's first Prime Minister. The country became a republic in 1962. Nyerere was the country's first president. In 1964, Tanganyika united politically with Zanzibar and was renamed Tanzania. Nyerere was unopposed as the first president of the new country.