Nigerian president Mohammadu Buhari has met with the freed remaining passengers from the train attack in March in the northwestern part of the country. The attack saw dozens kidnapped and six others killed.
General Leo Irabor, Nigerian Chief of Defence Staff confirmed the release of the remaining hostages qnd presented them to Buhari on Thursday.
"Thankfully, the balance of the 23 are here. I'd like to once again thank you Mr President for all the support that you've given that has led to this feat." said General Leo Irabor, Nigerian Chief of Defence Staff
A team had secured the release and took custody of passengers "held hostage by Boko Haram Terrorists following the attack on the Abuja to Kaduna train," a statement from a military committee said, without giving details on how they were freed.
Security is a major concern for Nigerians as the country prepares for February elections to replace President Muhammadu Buhari, a former army general who is stepping down after two terms leading Africa's most populous country.
No group claimed the March 28 train attack though officials have blamed jihadists cooperating with heavily armed criminal gangs who terrorise parts of northwest and central Nigeria with looting raids and mass abductions.
Analysts said the sophisticated attack involving explosives showed Islamist militants could have participated.
Nigerian government officials often use the term Boko Haram loosely to refer generally to armed groups.
After halting the high-speed train, the gunmen opened fire on coaches before herding passengers from the train's so-called VIP section into the bush.
A week later, they freed one hostage -- a top bank executive -- as a goodwill gesture for the Muslim Holy month of Ramadan.
Groups of other train hostages had been released after negotiations earlier in the year.
The Kaduna train attack was one of several major incidents this year underscoring the challenge facing Nigeria's overstretched security forces.
In July, Islamic State group affiliates claimed a bold attack on a prison just 40 kilometres (25 miles) from Buhari's presidential villa in the capital, in a military embarrassment.
That attack -- the first major assault around the capital since 2014 -- showed militants were capable of threatening areas beyond their northeastern bastion.
Officials have become increasingly concerned that militants are cooperating for pragmatic reasons with criminal bandit gangs in the northwest, who are motivated by profit rather than ideology.
Nigeria's military is battling on multiple fronts -- a 13-year jihadist insurgency in the northeast, criminal militias in the northwest and separatist tensions in the country's southeast.