“No Danish soldiers were injured, but five pirates were shot,” the military said.
“Four of the pirates died. One was injured,” it added.
The incident occurred on Wednesday when the frigate Esbern Snare, which has been patrolling the area since early November, attempted to board the pirate boat.
The Danish forces fired warning shots, and the pirates immediately fired back.
“The Danish soldiers acted in self-defence and returned fire,” the statement said.
Danish Prime Minister Mette Frederiksen told a news conference that the soldiers’ intervention had “probably prevented concrete pirate attacks against vessels in the region.”
Frederiksen, who had been scheduled to visit the Danish ship later Thursday during a visit to Ghana, said the Esbern Snare had “made an important and significant contribution to security in the Gulf of Guinea.
Her visit to the ship has been cancelled, Danish news wire Ritzau reports.
The head of the federation of Danish shipowners, Anne Steffensen, praised the intervention.
“The presence of Danish soldiers is absolutely necessary and, even if this appears harsh, piracy has a price,” she said.
After the shooting, the pirate ship sank and the eight pirates were brought aboard the frigate, where a seriously injured one of their number was treated.
“We do not yet have verified information about the nationality and hereby national connections of the four pirates who are still alive and one who is seriously injured,” Frederiksen said to Ritzau.
A piracy hotspot stretching 5,700 kilometres from Senegal to Angola, the Gulf of Guinea saw 195 attacks in 2020.
The same year, 130 of 135 hostage takings at sea occurred in the region, according to the International Maritime Office.
The Danish helicopter-equipped frigate and its 175 sailors “are fulfilling an important task by protecting Danish and other commercial vessels in the region,” Defence Minister Trine Bramsen told Ritzau.
Copenhagen in March announced it was sending the vessel to patrol the zone, where some 40 Danish ships operate daily.