The explosion happened at about 8:20 pm (1920 GMT) in the Jambutu area of the Adamawa state capital, although it was not immediately clear whether it was caused by a suicide bomber or an improvised explosive device.
"So far, we've recorded about 32 dead and about 80 injured," said Sa'ad Bello, the Yola coordinator for the National Emergency Management Agency.
The Red Cross and state police gave a slightly lower toll of 31 dead and 72 injured.
Buhari this month was in Yola to decorate soldiers for bravery in the counter-insurgency as well as visit a camp for people displaced by six years of violence that has left at least 17,000 people dead.
More From This Section
He told troops he believed Boko Haram "are very close to defeat" and urged soldiers "to remain vigilant, alert and focused to prevent Boko Haram from sneaking into our communities to attack soft targets".
Red Cross official Aliyu Maikano and residents said the area targeted was a lorry park which also houses a livestock market, an open-air restaurant and a mosque.
"Victims could be lying all over the place," Maikano said.
Tuesday's blast was the first in Nigeria this month, indicating the army's strategy to cut off the Islamists' supply lines and target their camps was paying off.
Buhari has set his military commanders a deadline of the end of next month to crush the rebels, who have increasingly taken to attacking border areas of neighbouring Chad, Niger and Cameroon.
But the Yola explosion also shows the difficulty in completely neutralising the threat, particularly in crowded urban areas.
Yola had been seen as a relative haven from the bloodshed across the northeast and last year housed hundreds of thousands who fled their homes as the militants advanced into Adawawa state.
The military declared the state "cleared" earlier this year.