President Paul Biya said the hostages, seized in May and July close to its northern border with north-east Nigeria, were now safe.
The Chinese workers were abducted in May near the town of Waza, 12 miles from the border. The others freed include the wife of Cameroon’s vice-prime minister who was kidnapped in July.
Boko Haram is seeking to establish an Islamic caliphate in Nigeria but its fighters often cross the long and porous border with Cameroon.
Many Nigerian civilians in border towns have fled to Cameroon to escape Boko Haram attacks, which have been stepped up in recent months.
Cameroon, Nigeria, Chad and Niger recently agreed to form a 2,800-strong regional force to tackle the militants.
“The 27 hostages kidnapped on 16 May at Waza and on 27 July at Kolofata were given this night to Cameroonian authorities,” Biya said in a statement, read on state radio.
“Ten Chinese, the wife of the vice-prime-minister Amadou Ali, the Lamido [a local religious leader] of Kolofata, and the members of their families kidnapped with them are safe,” he added.
Boko Haram has killed hundreds of people this year, mostly in north-east Nigeria, although its fighters have carried out bomb attacks across the country. The group made international headlines after it abducted some 200 Nigerian schoolgirls from a boarding school in April. They are believed have been taken to Boko Haram camps in the vast Sambisa forest, which straddles the border with Cameroon.
Militants have since stepped up cross-border attacks into Cameroon, which has deployed troops to its northern region and has joined in international efforts to find the abducted schoolgirls.
In July, Cameroon said Ali’s wife and maid were kidnapped in “a savage attack” on his home in Kolofata by Boko Haram militants – Ali managed to escape.
Boko Haram has been active in Nigeria since 2003 and is loosely modelled on the Taleban in Afghanistan.
Its name means “western education is sinful”, and the group has killed thousands of people in a violent bid to install Sharia law in Nigeria.
Boko Haram is concentrated mainly in the northern mainly Muslim states of Nigeria and consider all people, whether Christian or Muslim, who do not follow its strict ideology as infidels.
The group has waged guerrilla war on the state and attacks have focused on soft targets including children, students, teachers and other civilians.
Churches, mosques, newspaper offices, the security forces, politicians and a United Nations building have been targeted in attacks. Last May around 300 people were killed by gunmen who stormed the north-east town of Gamboru Ngala. The town had been left unguarded because soldiers based there had been sent to search for the missing schoolgirls.
Boko Haram’s insurgency is said to have cost at least 3,600 lives so far, including killings by security forces. However, it is likely the actual death toll is much higher.