Samia Suluhu Hassan looked solemn during proceedings that saw her make history to become Tanzania’s first female president.
The 61-year-old took her oath of office in the commercial capital, Dar es Salaam.
The chief justice oversaw proceedings, which took place two days after the death in office of President John Magufuli.
Ms Samia, who comes from the semi-autonomous islands of Zanzibar, had served as Mr Magufuli’s deputy since 2015 – and they were both elected for a second term in October.
Soon after taking the oath, a 21-gun salute was fired in her honour as the new commander-in-chief of the armed forces.
She then inspected a military parade and the flag of the presidency was raised, but only to half-mast as the country is in mourning.
The swearing-in took place at State House in Tanzania’s most populous city.
A condolence book for Mr Magufuli has been set up in the grounds of State House, which Ms Samia signed.
The events were broadcast on state television. Affectionately known as Mama Samia, a name in Tanzanian culture that reflects the respect she is held in, she called for unity in her inaugural speech.
“This is a time to bury our differences, and be one as a nation. This is not a time for finger pointing, but it is a time to hold hands and move forward together,” she said.
Analysts say the remarks are aimed as dispelling questions over how Magufuli’s illness was handled. It was announced on Wednesday that he had died from heart complications.
He had not been seen in public for more than two weeks, and rumours had been circulating about his health – with some opposition politicians saying he had contracted coronavirus.
Loved by his supporters for his no-nonsense approach, he was also a controversial leader, especially over his handling of the coronavirus pandemic.