One night in february 2011, the Ocean Mariner, a 450-foot chemical tanker, was sailing in the Gulf of Guinea near the coast of Benin, a small but strategically vital West African nation. Laden with 11,000 tons of oil and diesel worth approximately $10 million, the Mariner was at cruising speed – 11 knots – heading to Nigeria to refuel. At one point, the duty officer spied a fishing trawler two miles away. Then he noticed that a speedboat filled with armed men had launched from the trawler's deck. Before the Mariner's crew could do anything, the men had reached the ship, tossed a hooked rope over the railing, and shinnied up the hull. "They took us totally by surprise," one sailor recalls. Brandishing Kalashnikovs, a machine gun, and rocket-propelled grenades, the eight men punched the duty officer, slapped around other crew members, and ordered the communications officer to sever radio contact and disable the satellite tracking device. They placed the crew under guard in the mess hall and then marched the captain and chief officer to the bridge, saying, "Steer where we tell you to steer."

The Ocean Mariner navigated out into the open sea. The pirates paced the deck, working their satellite phones in search of a broker in neighboring Nigeria who was willing to purchase the stolen fuel and charter a tanker to "load and lift" it off the Mariner. Forty-eight hours later, they hooked hoses up to two smaller tankers and drained the Mariner's tanks. When those were empty, the pirates, $10 million wealthier, disappeared.Last year, while the world focused on the problem of piracy in the waters off Somalia, a similar phenomenon was taking place, almost unnoticed, here in the Gulf of Guinea, one of the world's primary oil-shipping corridors. Over the course of 2011, 30 oceangoing ships – oil tankers, mostly, bearing fuel to be sold in global markets – were hijacked in international waters off Benin. At least 15 more were raided and robbed in the vicinity of the country's 12-mile territorial limits. Between May and September, the peak of the piracy wave, "ships were being attacked every night," says Anders Ostergaard, chief executive officer of Monjasa A/S, a major supplier of fuel to ships traveling in the Gulf of Guinea, as well as the company that had leased the Ocean Mariner. Last summer, Lloyd's Market Association, a consortium of maritime insurers, placed Benin in the same high-risk category as Somalia.

In Cotonou, Benin's economic capital, I pay a visit to Major Regis Ahoueya, commanding officer of the Cotonou Naval Base. Ahoueya is hunched over a computer screen, watching a dozen black blips inch across a field of blue and green. Blue means territorial waters, green international, and each blip represents a vessel off the coast. The program, known as Automatic Identification System (AIS), allows Ahoueya to track the movements of every vessel in Benin's waters in real time. Ahoueya says that before AIS, donated by Nigeria last summer, the navy was "flying blind."

Ahoueya speaks idiomatic English, the result of a year's training with U.S. Marines in Quantico, Virginia. "I came back from the States and wanted an assignment that was a little more physical," he tells me. "And I found it." Cotonou was becoming an international shipping hub. Lagos, in Nigeria, had grown corrupt and unmanageable, and ships coming through the Gulf of Guinea preferred Cotonou for picking up and delivering crude oil and other commodities. "Cotonou became the new mecca," says Ostergaard. "We went there all the time, and everybody was happy."

That was, until the piracy wave began and Benin's naval fleet, which consisted of outmoded Chinese patrol boats and two Boston Whalers, was unable to protect itself against armed marauders. In 2011, Ahoueya participated in five seaborne rescue attempts – all of them unsuccessful – including two in one day. "For six months, I couldn't sleep," he says. "They're calling you, 1 am, 'I'm attacked!' – 2 am, 'I'm attacked!'"The root of Benin's piracy problem is not in Benin but rather several hundred miles to the east, in Nigeria's Niger Delta. Since the 1990s, rebel groups have raised untold millions of dollars through antigovernment actions against that oil-rich country – kidnapping and ransoming expatriate oil workers and "bunkering," or siphoning fuel, from the pipelines that crisscross the region. In 2009, the Nigerian government reached a cease-fire with the most important of the resistance groups, the Movement for the Emancipation of the Niger Delta, or MEND, in which it agreed to make cash payouts to insurgents who put down their arms. The delta went quiet for a while. Soon, though, many MEND operatives broke the accord because the money from the government never arrived and the potential profit in crime was too large. "Somalia was an object lesson," says Sam Olukoya, a BBC correspondent in Nigeria. "They could take criminality to a very high level."

A brutal year for piracy in Nigeria was 2010, with at least 25 vessels attacked or hijacked off the coast. The hijackings threatened to disrupt oceangoing commerce in the world's 12th-largest oil producer, which provides the U.S. with about eight percent of its oil imports. The Nigerian navy responded by improving its intelligence-gathering network and strengthening its fleet with nine additional patrol boats and two former U.S. Coast Guard cutters. The U.S. government, alarmed by the threat of a spike in oil prices, increased its efforts to train the Nigerian navy and dispatched naval speedboats to key junctions in the delta's creeks, monitoring suspicious boat traffic. A year later, pirate attacks off Nigeria had dropped to just 15.

Unfortunately, the pirates hadn't disappeared – they'd just transferred operations to Benin. Fernand Maxime Ahoyo, then chief of staff of the Benin navy, had predicted this would happen. "I warned that if we didn't do something quickly to improve security, there would be chaos," he says. "But nobody took care in what I was saying."The ocean mariner hijacking was a wake-up call to the threat in Benin's waters, says Ostergaard. It seems, however, that some companies, Monjasa included, slept through it, since there were more attacks to come. On May 8, at 4:45 am, four pirates came in through the engine-room skylight of the Energizer, a Monjasa-owned oil tanker delivering fuel off the coast of Cotonou. The men grabbed the chief engineer, pointed knives in his face, and ordered him to guide them to the captain's cabin. They stole laptop computers and cash from the captain and crew, and then fled.

Monjasa ratcheted up its safety measures. It established "citadels" on its tankers: fortified engine rooms without windows, in which crew members could seal themselves. Antipiracy drills became routine, and GPS locators were embedded in every vessel so that, says √òstergaard, "even if the pirates knocked out our communications system, we'd know where to find the ship."

Sensible as these measures were, they didn't completely remove the danger. In September, pirates attacked the Energizer again. The crew retreated to the citadel and cut the power so the attackers couldn't maneuver. After trying for two hours to reach the navy's emergency line, the Energizer's onshore shipping agent roused Major Ahoueya from bed. By the time a rescue arrived, the pirates were long gone.

Monjasa now, like many other companies, refuels ships in safer waters in Togo.Ahoueya insists that the Benin navy is improving and that the risk of interrupted shipments of oil in the gulf – and a spike in worldwide oil prices – has decreased. The force supplemented its paltry fleet with two $460,000 U.S. Coast Guard Defender-class speedboats, a gift from the U.S. government. The Nigerian navy launched round-the-clock joint patrols with its Benin counterpart, contributing seven naval vessels to the program. Following Nigeria's example, Benin set up five "anchorage zones," where ships can transfer fuel and cargo under naval protection. And it is awaiting delivery of two high-speed, long-range vessels and two surveillance aircraft, both from France. Last November, Ahoueya and his men achieved their first arrests at sea: A joint patrol captured a gang of eight pirates as they were traveling in a speedboat that had participated in an attack the previous spring.

Ahoueya arranges for me to accompany commandos on an evening patrol in the Gulf of Guinea. Hours later, I'm clutching the gunwale of a 24-foot Defender-class speedboat as it races out of Cotonou Harbor. Ensign First Class Gaston Affaton scans the rough seas from the cramped aft deck, while two junior ensigns, armed with rusty Kalashnikovs, hunker down in the cockpit. Affaton points to the twin 225-horsepower outboard engines that propel the craft. "A couple of years ago, we were defenseless," he tells me, as we bounce at 45 knots past oil-storage tanks and docked cargo ships. "Now we are able to defend ourselves."

The U.S. is concerned that rising piracy in the Gulf of Guinea could not only wreak havoc in the global oil market but also cripple regional economies and destabilize Benin and other fragile democracies. In a region that has experienced civil war, anarchy, and horrific suffering in recent years – think Liberia and Sierra Leone – the U.S. and other wealthy nations have a vested interest in preventing another meltdown that might cry out for a multilateral intervention. Nigeria, too – whose oil accounts for 90 percent of its export revenue and 40 percent of its gross domestic product – desperately wants to reassure the shipping industry that the Gulf of Guinea is safe. Yet getting a handle on piracy will take far more than pledges of cooperation and a smattering of fancy equipment bestowed by France and the U.S. The larger issues driving the crisis – poverty and corruption – remain endemic across the gulf, and until those are dealt with in a forthright way, the prognosis for a long-term solution isn't good.

Darkness has fallen on the Gulf of Guinea, and the lights of Cotonou Harbor twinkle through the murk. The tour is nearly over. Heading back to shore, the Defender comes upon a rust-bucket trawler fishing too close to the port, in violation of Benin law. Spotting the Defender, the crew quickly pulls up its nets. The men deny that they were fishing, insisting that the nets were "stuck" in the water.

Then something unexpected happens. Affaton turns to me and says, "Go inside the cabin, and don't come out." Through the windows, I watch the commandos shake down the fishermen, first demanding cash and then settling for the day's catch. The crew dumps a sizable pile of fish on the bow of the boat, and the Defender speeds back to port. Affaton and his crew appear pleased, laughing among themselves. In the dangerous and unruly waters off the coast of Benin, you're never truly safe from pirates.