How did Tanzania become independent?

Tanzania became independent when Julius Nyrere became president of the territory of Tanganyika and invited the island of Zanzibar to join it, forming the United Republic of Tanzania