The remote jungle encampment had been surrounded by troops and snipers. Vice Governor Santiago Cane of Agusan del Sur province said the hostages left aboard two army trucks. The gunmen - former government-armed militiamen - then surrendered their assault rifles, grenades and ammunition.
"Declaring officially that all hostages are free. Yes, at last," Cane told reporters in a cellphone message.
Looking tired but relieved after three days in captivity, the mostly male hostages waved and smiled at journalists and army troops waiting at a nearby muddy village.
All wore new white shirts given by government officials who fetched them. They will be taken to a hospital in Agusan del Sur's capital town of Prosperidad, about 515 miles (830 kilometers) southeast of Manila, for a checkup.
The hostage crisis began Thursday when the gunmen, led by Joebert Perez, abducted more than 70 people from a village school and surrounding houses after police attempted to arrest him on a murder charge. Several schoolchildren and women were freed earlier, leaving 47 in captivity.
The crisis ended after Perez signed an agreement Sunday with government negotiators to free his hostages in exchange for a pledge that he and his men will not be arrested for either the abductions or past murder charges that arose from a violent land dispute with another clan.
Government negotiators, invoking a law that protects the rights of ethnic groups, agreed to Perez's demand to have his case handled by a tribal court. Police also promised to disarm his rivals, whom Perez has accused of killing some of his relatives over the land dispute, officials said.
The kidnappings were the latest in a series of security crises that have gripped the Philippines' volatile south, including a jailbreak by Islamic militants Sunday on the island province of Basilan, and a massacre of 57 people, including 30 journalists, allegedly by members of a powerful clan and loyal militiamen in Maguindanao province.
The involvement of former and active militiamen in the hostage-taking and the Maguindanao massacre have sparked calls for the disbanding of paramilitary forces, which have been armed by the government to help in counter-insurgency assaults.
The militias, drawn from the ranks of the unemployed, landless farmers, former rebels and ex-soldiers, have become notorious for abusing civilians, looting homes or ending up as private armies of political warlords.