Police Commissioner Mussa Ali Mussa said 145 people had been rescued and that the rescue mission was suspended until morning.
The ferry, MV Skagit/Kalama, set sail from mainland Tanzania at around midday for Zanzibar, Tanzania's semi-autonomous archipelago and a popular tourist destination.
"The latest count that we have is 31 people dead and 145 were rescued. We have suspended the rescue operation for the night, but we will resume it at first light in the morning," Mussa told Reuters by telephone.
"The passenger boat had between 250 and 300 people on board when it capsized in rough seas."
Government spokesman Yusuf Chunda said a foreigner was among those killed, but it was not clear how many others had been on board the vessel.
"One foreigner, a woman, is among the dead. Thirteen other foreigners were rescued and are in hospital," Chunda said.
Earlier, police said the vessel was carrying 250 adult passengers and 31 children when it capsized near Chumbe island, west of Zanzibar.
Zanzibar police spokesman Mohammed Mhina said by telephone that many passengers were missing but added "we don't know how many of them sank with the boat".
"Almost the entire boat has been submerged in water ... only a small part of the boat is now visible."
The ferry is owned by a company named Seagull, which also runs a number of other ferries. Previous reports had indicated the vessel was called MV Salama.
More than 200 people were killed when a crowded ferry sank in September off the coast of east Africa in the worst maritime disaster in the history of Zanzibar.