Prime Minister Stephen Harper is praising the crew of a Canadian warship after they helped chase and detain Somali pirates who tried to attack a Norwegian tanker in the Gulf of Aden.

Speaking to reporters at the Summt of the Americas in Trinidad and Tobago, Harper said the crew had done "tremendous work" in the operation.

He also noted that Canada had "acted within our legal authority and also within our capacities."

HMCS Winnipeg, patrolling with other NATO vessels off the Horn of Africa, responded to a mayday call issued by the Norwegian-flagged vessel Front Ardenne after a band of pirates approached the vessel late Saturday, officials said.

The pirates fled after the Front Ardenne alerted nearby warships.

The Winnipeg gave chase, along with U.S. and British ships, and warning shots were fired to get the pirates to stop, Canadian military officials said. After several hours of pursuit, Canadian sailors boarded the small skiff and detained the group.

They found a rocket-propelled grenade, said HMCS spokesperson Michael McWhinnie. But after further interrogation, the pirates were released.

"We obviously act within our legal capacities, and also within our capacities," said Harper. "In this case we briefly detained the pirates and disarmed them, and I think those were the appropriate measures under those circumstances.

"Obviously, Canada always uses force when necessary, but only when necessary."

Canadian forces had to release the pirates because they cannot be prosecuted under Canadian law as they did not attack Canadian citizens or interests and no crime was committed in Canadian territory, NATO officials said.

Pirates have attacked more than 80 boats this year, about four times than in 2003, according to the International Maritime Bureau.

Pirates currently control at least 18 ships and hold more than 300 crew hostage.

HMCS Winnipeg and the American ship USS Halyburton, which also took part in this weekend's operation, are part of an anti-piracy NATO force patrolling the Gulf of Aden, a busy transport short cut between Europe and Asia.

With files from The Associated Press