The presidency has announced the death of "scores of people" in an attack in Sokoto on Saturday.
The presidency said the attack occurred in "three communities in Rabah Local Government Area (LGA) of Sokoto State."
Sokoto, like neighbouring Zamfara and Katsina states, has witnessed random attacks by armed men who kill and also kidnap for ransom.
The statement by Garba Shehu, who signed as Mr Buhari's spokesperson, stated that Mr Buhari "expressed deep shock and sadness" over the incident.
Some of those killed in the attack were buried on Sunday, the News Agency of Nigeria (NAN) reports.
Governor Aminu Tambuwal of Sokoto was among those who attended the funeral of 25 persons killed in the attack.
NAN, which put the death toll at 25, reports that Mr Tambuwal together with heads of security agencies, traditional rulers and government officials later condoled the families of the victims after the burial held at Gandi town.
NAN gathered that the bandits who were in large numbers raided Kalhu, Tsage and Geeri villages near Gandi and killed the 25 persons.
The attackers were said to have engaged in indescriminate shooting from around 5pm on Saturday till Sunday morning, after which they carted away hundreds of cows, sheep and other valuables.
Rabah has been experiencing bandits' attacks in recent time, with people losing their lives while many others who were rendered homeless are now taking refuge at an Internally Displaced Persons camp in Gandi.
Mr Tambuwal pledged that the government would take more measures "to end such uncivilized and barbaric attacks", and urged community members to assist security agencies with useful information to track the bandits.
Speaking to journalists, Sokoto state Commissioner of Police, Ibrahim Kaoje, said four persons including a woman informant who pretended to be a lunatic were arrested.
Mr Kaoje said that a joint security operation was in progress to contain banditry and other crimes in the state.
The state Chairman, IDPs' Welfare Committee, Lawal Maidoki, said relief materials had been delivered to the victims.
NAN reports that with the present 25 killed in the latest attack, the total number of persons killed by bandits in Sokoto State has risen to at least 108 from 2018 to date.
Other places affected by armed bandits' attacks were Dalijan, Rakkoni and Tabanni communities within the period.
In his statement on Saturday's attack, Mr Shehu said "the President, who was briefed about the incident and the arrests so far made by the police, condoles with Governor Aminu Tambuwal and the people of the State over the tragic incident.
"President Buhari strongly condemns all acts of violence and terrorism against innocent Nigerians, reiterating that perpetrators and sponsors of such dastardly acts would be held accountable under the law.
"The president prays for the quick recovery of all those injured and assures that his administration will not relent in the fight to neutralise terrorists, bandits and kidnappers around the country."