The boys were flanked by armed police as they walked in single file from the buses to a government building to meet the governor. They were also due to undergo medical checks.
One boy told a TV station that the group had been fed bread and cassava during their captivity and said it had been cold. He said was “really happy” to be back in Katsina.
Parents were overjoyed to be reunited with their sons. “I couldn’t believe what I heard until neighbours came to inform me that it’s true,” Hafsat Funtua, whose son is 16, told Reuters news agency.
How was the boys’ release secured?
The government insists no ransom was paid but that the boys were released after negotiations with the kidnappers.
Although Islamist militant group Boko Haram said it was behind the kidnapping, this has been denied by Nigerian officials.
Zamfara state governor Bello Matawalle, in whose state the boys were released, told the BBC that three separate negotiations had taken place before the boys’ freedom was secured.
They were released in Tsafe town in Zamfara on Thursday evening, authorities say.
Mr Matawalle told BBC Hausa that during the negotiations the kidnappers raised various grievances.
“Among their complaints was how people kill their cattle and how various vigilante units disturb them,” the governor said, adding that the government had promised to look into the complaints of the kidnappers.
Conflict between herders and farming communities are common in Nigeria’s central and north-western states, says the BBC’s Nduka Orjinmo in Lagos.
Both groups have been warring for decades but deadly clashes have increased in recent years as farming communities and herdsmen have employed armed vigilantes, especially in Nigeria’s north-west.
How did the school attack unfold?
Witnesses said armed men raided the school in Kankara town last Friday evening. Many students jumped the school fence and fled when they heard gunshots.
Some were tracked by the gunmen, who tricked them into believing that they were security personnel, students who escaped said. Once these students were rounded up, they were marched into the nearby forest by the armed men.
On Thursday, video was released bearing Boko Haram’s emblem, showing dozens of boys, some of whom appear to be very young.
One of the boys said they were kidnapped by Boko Haram leader Abubakar Shekau’s group and that all the government troops who had been sent to help them should be turned back.
What’s the wider picture?
Boko Haram has become notorious over the last decade for school kidnappings, including one in Chibok in 2014, when nearly 300 schoolgirls were seized. The group’s name loosely translates as “Western education is forbidden”.
However, these abductions have until now taken place in north-eastern Nigeria, where Boko Haram is based.
Armed attacks and kidnappings are rife in north-western Nigeria and are often blamed on bandits, a loose term for gangs operating in the area.
Amnesty International says more than 1,100 people were killed by bandits in the first six months of this year, with the government failing to bring the attackers to justice.