For centuries, the Strait of Malacca has been one of the great thoroughfares of global commerce. In the old days of wood and sail, the 500-mile ribbon of water, which connects the Indian and Pacific oceans between Malaysia and the Indonesian island of Sumatra, carried pricey spices from the islands of the Indies to the eager markets of the West. Today, about 40% of the world's trade passes through the strait on 50,000 vessels that ply its waters every year. Oil from the Persian Gulf flows east to China and Asia's other voracious economies, which in turn send back manufactured goods to the Middle East and Suez Canal.

With such juicy pickings, it's no wonder that the strait has long been a popular hunting ground for pirates. The sheer quantity of ships passing through its confined space  at one point the strait narrows to a mere 1.7 miles  makes spotting potential targets easy for pirates, and its route is a Hollywood-ready seascape of tropical isles and secret coves, providing ample hideaways. Earlier this decade, the waterway's piracy problem reached crisis levels. Attacks ranged from small-scale robberies by lightly armed desperados to highly organized hijackings of giant vessels by teams of professionals. According to the International Maritime Bureau of the International Chamber of Commerce, the Strait of Malacca suffered 38 actual or attempted pirate attacks in 2004, the second highest total in the world after Indonesia. "We don't stand a chance" against the pirates, an Indonesian naval officer conceded at the time. In 2005, the London insurance market added the strait to its list of areas at risk of war. (See pictures of a pirate-hostage rescue in Africa.)

But today, it's the pirates who are on the run. While piracy in Africa has become a major international security concern, the problem in the strait has been almost completely eradicated. Only two attacks were attempted there in 2008, even as the global total reached a record high. In the first quarter of 2009, the bureau reported that the number of pirate attacks around the world nearly doubled, to 102 incidents, compared with the same period last year; only one of them occurred in the Strait of Malacca. (Read a brief history of pirates.)

What happened? Maritime security analysts say a combination of factors  both on sea and land  contributed to the pirates' near total defeat. Most significantly, the success in the strait shows how concerted and well-coordinated action by regional governments can prevent pirate attacks on commercial shipping. "From Roman times to the Barbary pirates, throughout history, the reasons [for resolving piracy] are always the same," says Pottengal Mukundan, director of the International Marine Bureau in London. "For pirates, it becomes a much riskier activity. That is really the deterrent."

Until recently, that deterrent simply didn't exist in Malacca. The main countries along the route  Malaysia, Indonesia and Singapore  were not working together. With their militaries distrustful of one another, the governments almost never shared information on pirate activities, allowing them to operate unchecked. But in 2004, the piracy problem became so severe that it was threatening local economies  especially Malaysia and Singapore, which rely heavily on trade for economic growth. Fears were also raised in regional capitals that outside powers  whose own trade was being affected in the seizures  would intervene in the strait if the local governments didn't solve the problem themselves. A new spirit of cooperation took hold along the strait. "All of us shared the same goal and objective," says Zahari Jamian, a captain in the Royal Malaysian Navy, "to paint the picture to the world that the strait is not really a war-risk zone."

The results were a series of measures taken collectively, mainly by Singapore, Malaysia and Indonesia, with some cooperation from Thailand, that significantly improved security in the strait. Beginning in 2004, the local armed forces organized coordinated sea patrols. Each side polices its own territorial waters, but they communicate with one another on potential pirate activity, greatly enhancing the effectiveness of the patrols. In 2005, they added regular sorties of airplanes to scout the strait for pirates. The flights are undertaken by crews with nationals from the different countries so they can better share information. Intelligence gathered on pirates is also disseminated among governments, including on a Web-based network for quick and easy access. These actions, taken together, made it far more costly and difficult for the pirates to operate. "It dawned on the states that piracy is transnational and nothing that could be handled by one nation alone," says Nazery Khalid, senior fellow at the Maritime Institute of Malaysia in Kuala Lumpur. "The sea doesn't respect borders."

Defeating the pirates, however, took more than sea power. Combined with the greater military deterrent, many potential pirates' outlook in the region improved. Analysts believe that some of Malacca's pirates came from the Indonesian territory of Aceh on the far western tip of the island of Sumatra. That region had been torn apart by a three-decade battle between a local Islamic separatist group and the Indonesian military, isolating Aceh and annihilating economic opportunities. Desperate Acehnese took to piracy as the only way to earn a living, while arms-smuggling operations spawned by the conflict added an organized, criminal element to the strait. But in 2005, the two parties finally signed a peace accord and normalcy returned to Aceh, opening up less-risky job options on land. "The impetus for piracy began to change," says Alex Duperouzel, managing director of Background Asia Risk Solutions, which provides security for vessels. "You have to solve the problem on land, or you don't solve the problem." (Read how Somalia's fishermen became pirates.)

The case of Malacca gives at least a glimmer of hope that the piracy problem in Africa can also be tackled. The success in the strait clearly shows how committed and carefully orchestrated naval action can combat pirates. But analysts warn that the lessons of Malacca also tell us how much more difficult fighting the Somali pirates will be, because of the very different conditions on shore in Africa. The countries along the strait possess the resources and organized governments necessary to stand up to piracy. Those crucial elements are lacking in destitute and disorderly Somalia, where most of the pirates that are terrorizing the Gulf of Aden hail from. That fact alone makes the situation in Malacca and Somalia "completely different," warns Nazery of the Maritime Institute. "Piracy, whatever happens at sea, is symptomatic of a different problem  the instability of the political situation in Somalia," he says. As the nations along the Strait of Malacca learned, fighting pirates in the long term takes a lot more than some swashbuckling.