The naval boat's captain Commander Regis Ahoueya told Reuters that a dozen heavily armed pirates had boarded the two ships, which were carrying diesel just off the coast of the west African state of Benin, between 1.30 a.m. and 2 a.m.
"We received the distress alert of the two ships simultaneously, and we immediately went to the scene," he said. "We defeated the pirates and urged the two ships to head back to the coast. They are under our control. The worst would have happened if we'd got there even a few minutes later."
Stretching from Guinea on Africa's northwestern tip down to Angola in the south, the Gulf spans a dozen countries and is a growing source of oil, cocoa and metals to the world's markets.
While piracy has yet to hit the levels seen off Somalia, it is likely to intensify further unless the region's weak naval and coastguard defences are beefed up.
Last Sunday, pirates attacked an Italian tanker carrying a cargo of diesel fuel off Benin, making off with some goods but leaving the crew unharmed. A few days before that, pirates released a Greek-owned, Liberia-flagged tanker they had seized, also off the coast of Benin.