NAIROBI, Kenya (AP) — Two rival groups of Somali pirates had a shootout just before a ransom was delivered to free a supertanker loaded with combustible crude oil, prompting the pirates onboard to call the anti-piracy force for help, a European Union naval spokesman said Monday.

Helicopters dispatched from a warship ended the standoff that could have caused a catastrophic explosion aboard the Maran Centaurus, which is carrying about 2 million barrels of crude oil that was destined for the United States. The ship's cargo is so flammable that smoking is forbidden on deck.

The supertanker was seized about 800 miles (1,300 kilometers) off the Somali coast with a crew of 28. The crude oil onboard was estimated to be worth roughly $150 million at the time of the Nov. 29 attack.

Cmdr. John Harbour, the spokesman for the European Union Naval Force, said a group of rival pirates had attacked the gunmen holding the Greek-flagged ship on Sunday just before the ransom was being delivered, prompting the pirates onboard the tanker to call for assistance from the anti-piracy force.

A Somali middleman, who helped negotiate the ship's release, said a nearby warship had dispatched two helicopters to hover over the attackers' two skiffs, frightening them off. The pirates onboard the ship then collected $5.5 million, which was parachuted out the back of two planes, he said. The pirates left the ship Monday morning and the helicopter did not fire any shots, he said.

He also said that he had spoken to the group of pirates attacking the ship, and that their intention was to force the original gunmen to give them a cut by using a show of force, rather than trying to storm the ship. Both sides knew of the potential for a catastrophic explosion, he said, and that is why the original pirates asked the EU for aid.

The middleman spoke on condition of anonymity because he said he feared reprisals.

Harbour could not confirm the amount of ransom paid or whether the EU warship in the area, the Greek FS Salamis, had intervened in the pirate dispute. In a statement later, the EU naval force said it dispatched a helicopter to provide any immediate medical assistance to the crew on the ship that is now under naval escort as it leaves Somali waters.

In a statement, the ship's owner declined to give any details about how it negotiated the release of the Maran Centaurus. The Maran Tankers Management Inc. said the crew are safe and well.

A Greek coast guard spokeswoman said the tanker had left Somalia escorted by a Greek frigate and was heading to the South African port of Durban. She said all crew members were in good health, and the ship was expected to reach Durban in a week. She spoke on condition of anonymity in line with Greek government regulations.

The ship, only the second oil tanker captured by Somali pirates, had 9 Greeks, 16 Filipinos, 2 Ukrainians, and a Romanian aboard. Its seizure resurrected fears of an environmental or safety disaster first raised by the capture of the Saudi-owned Sirius Star. That hijacking was resolved in January last year with a $3 million ransom payment. It was carrying 2 million barrels of oil valued at about $100 million at the time.

The International Maritime Bureau said last week that sea attacks worldwide surged 39 percent last year to 406 cases, the highest in six years. Somali pirates raids on vessels accounted for more than half the attacks.

It said that Somali pirates were responsible for 217 of the global attacks and had seized 47 vessels. This was nearly double the 111 attacks Somali pirates launched in 2008, of which 42 were successful hijackings.

The impoverished Horn of Africa nation has not had a functioning government for 19 years and the weak U.N.-backed administration is too busy fighting the Islamist insurgency to arrest pirates. Across the Gulf of Aden, tensions between north and south Yemen continue to rise and Islamic militancy is increasing.

Pirates now hold about a dozen vessels hostage and more than 200 crew members.