Pirate Bile Hussein told The Associated Press that armed forces from Somalia's semiautonomous northern region of Puntland tried to surround the village of Hul Anod and free the family but were beaten back before they were in position. He said some government forces were killed and others were captured but did not give exact figures.
"We defended ourselves and foiled their attempt to recover the Danish family," he said. "We have killed and captured some of their soldiers and burnt two (government) pickup trucks. They have run away back to where they came from. ... The hostages are safe and still in our hands."
A senior Puntland official said that five soldiers were killed and vehicles were burned. He said that government forces have retreated for now.
A Nairobi-based security official also confirmed the incident, citing information from Puntland authorities. He said the pirates ambushed the government forces on their way to the rescue mission.
Both officials spoke on condition of anonymity because they are not authorized to speak to the media.
Puntland officials were not immediately available for comment.
In Copenhagen, the Danish Foreign Ministry declined to comment on the foiled rescue attempt. "We don't have any comment because we don't have any information about the situation," ministry spokesman Folmer Jensen said.
The Johansens, their three children and two crew members were kidnapped two weeks ago after pirates seized their 43-foot (13-meter) sailboat. The botched attempt to rescue them comes weeks after another failed intervention, by U.S. forces hoping to save four American hostages. When U.S. special forces arrived, they found all four hostages had been killed by pirates; the circumstances that led to their deaths are still unclear.
Maritime experts said the Johansens had placed themselves in grave danger off Somalia's lawless coast, despite warnings from naval forces struggling to police the area against pirates.
A Somali pirate previously warned that if any attempt was made to rescue the family, they would be executed like the four Americans.
Somalia has not had a functioning government in two decades, and piracy has flourished off its coast. Maritime authorities say as ransoms have climbed into the millions of dollars, pirates are holding hostages for longer and becoming more vicious. On Wednesday, pirates freed the 25 crew members of the Rak Afrikana, who had been held for nearly a year.
Associated Press Writers Katharine Houreld in Nairobi, Kenya, and Louise Nordstrom in Stockholm, contributed to this report.