Mainland Tanzania ( formerly Tanganyika ) received independence in December 1961 , while Zanzibar gained her independence in January 1964 , through a revolution . The two countries joined together to form the United Republic of Tanzania in April 1964 .
The name Tanzania derives from the names of the two states Tanganyika and Zanzibar that united in 1964 to form the United Republic of Tanganyika and Zanzibar , which later the same year was renamed the United Republic of Tanzania .