SEOUL, South Korea  South Korean special forces staged a daring early morning rescue on a hijacked freighter hundreds of miles off the coast of Somalia on Friday, killing eight pirates and rescuing all 21 hostages, the South Korean military said.

President Lee Myung-bak, who was sharply criticized last year over what was deemed a weak response to the sinking of a warship and the North Korean shelling of a South Korean island, reaffirmed his country’s tough stance against pirates and appeared pleased with the operation in a televised statement.

“We will not tolerate any behavior that threatens the lives and safety of our people in the future,” Mr. Lee said.

Rescue operations on hijacked ships are rare, with countries often deciding against such attempts over concerns for the safety of the crew. Most shipping companies, in turn, opt to pay the expensive ransoms demanded by Somali pirates to release hijacked ships rather than engage in confrontations.