Tanzania's chief justice has sworn in John Pombe Magufuli as the country's fifth president in a ceremony attended by several African heads of state.

Chief Justice Mohammed Othman Chande also swore Vice President Samia Suluhu Hassan, the first female vice president in Tanzania.

Magufuli, whose Chama Cha Mapinduzi, or Party of the Revolution, for the first time faced tough competition since independence from a united opposition candidate, called for unity in the country in his acceptance speech.

Opposition candidate Edward Lowassa has rejected the vote, saying it was stolen and did not attend Magufuli's inauguration.