Gunmen opened fire near Daura on a convoy carrying an advance team of security guards, including DSS state security agents, presidential protocol and media officers, the presidency said in a statement late Tuesday.
"The attackers opened fire on the convoy from ambush positions but were repelled by the military, police and DSS personnel accompanying the convoy," it said.
"Two persons in the convoy are receiving treatment for the minor injuries they suffered. All the other personnel, staff and vehicles made it safely to Daura."
It was not immediately clear who carried out the attack.
Buhari was not in the convoy when gunmen ambushed the vehicles late Tuesday, injuring two people, but the attack underscored Nigeria's precarious security situation.
Buhari is expected to visit his hometown of Daura in Katsina State over the weekend for the Muslim religious festival of Sallah.
Buhari steps down next year after two terms in office with Nigeria's security forces still battling a grinding 13-year jihadist insurgency in the country's northeast and heavily armed criminal gangs who operate in the northwest.
Armed militias known locally as bandits often raid and loot villages and carry out mass abductions for ransom despite military operations against them in northwest and central Nigeria.