He said Gaddafi's army of trained gunmen are responsible for escalating the crisis.
The struggle for access and control of lands over which roaming herdsmen graze their cattle has led to conflict with local farmers all over the country, resulting in the death of hundreds just this year alone with herders credited with a majority of the attacks.
According to President Buhari, the conflict escalated due to Gaddafi's army of trained gunmen who escaped into Nigeria and started causing problems to local populations with their sophisticated weapons.
The president made his remarks in response to the Archbishop of Canterbury, Justin Welby, during a meeting between the two at the Abuja House in London on Wednesday, April 11, 2018.
He said, "The problem (herders/farmers conflict) is even older than us. It has always been there, but now made worse by the influx of armed gunmen from the Sahel region into different parts of the West African sub-region.
"These gunmen were trained and armed by Muammar Gadaffi of Libya. When he was killed, the gunmen escaped with their arms. We encountered some of them fighting with Boko Haram.
"Herdsmen that we used to know carried only sticks and maybe a cutlass to clear the way, but these ones now carry sophisticated weapons. The problem is not religious, but sociological and economic. But we are working on solutions."
The president had earlier blamed Gaddafi for some of the menace of terrorist group, Boko Haram, while he was speaking to the Nigerian community in Abidjan, Cote d'Ivoire in November 2017.
He said the instability in Libya was responsible for the escalation of the terrorist insurgency as many Nigerians who returned from the North African country were recruited by Boko Haram due to the nature of their work in Libya.
The president said, "After 43 years of Gaddafi where he recruited so many people from the Sahel including Nigeria and so on, all they learnt was how to shoot and kill. They didn't learn to become electricians, plumbers or any other trade. So, when the Libyans stood against their leader those who are not their people, they chased them out.
"A lot of them came back home with their workers, some of them participated in Boko Haram and become part of Boko Haram."
The president promised that his administration, in its bid to properly secure the country, will do its best to rehabilitate Nigerians who are coming back from Libya and make sure they're not indoctrinated.