A Palestinian smuggler climbs down into a tunnel, temporarily closed by Hamas forces, beneath the Egyptian-Gaza border in Rafah, April 14, 2010.
Ibraheem Abu Mustafa / Courtesy Reuters

The thousands of traders who swarm the once destitute corridor that marks Gaza’s southernmost boundary with Egypt call the area the “Rafah free zone.” They spend most of their day in hot, damp passageways a hundred feet underground, dragging rubber sleighs loaded with goods and then winching them to the surface.

Rafah long languished as a provincial backwater in the claustrophobic Gaza Strip, a clannish and rural hinterland to Gaza City’s bustling and cosmopolitan downtown. A few families controlled the limited tunnel trade that existed for decades. And even in the days when Gaza’s legal overland trade flourished, weapons and contraband were still smuggled into the Strip underground.

At first, in 2007, Hamas only tolerated the tunnel economy; but it began to embrace it the following year, legalizing and regulating subterranean trade. Hamas had found a spontaneous solution to the economic crisis that was threatening its rule of Gaza -- and, in the process, turned expediency into opportunity.

Opportunism as strategy appears to be the group’s new hallmark. When faced with only bad options to deal with the blockade or its status as a diplomatic pariah, Hamas has behaved as if it chose its predicament, leveraging its position into either greater control over Gaza or greater political influence beyond its boundaries. Desperation, in other words, has become an avenue to power.

The snaking tunnels, like Hamas’ contorted diplomatic campaign, grew out of the total isolation the movement faced after it won the 2006 Palestinian parliamentary elections. Israel and the United States both list Hamas as a terrorist group and immediately boycotted the new Hamas government. In the summer of 2007, Hamas took over Gaza after a quick but bloody clash with U.S.-trained forces from the Fatah faction. Since then, Israel has closed off all but the most basic trade and movement.

In response, Hamas moved to legalize the tunnels, charging licensing fees and opening up the “free zone” to a group of investors who would owe their profits and livelihoods to Hamas. Hundreds of new tunnels have opened every year since 2008. “We have run out of land for new tunnels,” Major Rafaat Salama, the police chief, cheerily told me.

Abu Tarek, now 32 years old, has worked in the tunnels his entire adult life. In three years, he has gone from poor laborer to middle-class contractor, one of the countless unintended beneficiaries of Israel’s blockade. “Before, it used to be a terrifying business,” he told me, standing at the mouth of one of the tunnels he had dug.

Now, Hamas police officers patrol the 1,000-plus tunnels, and Hamas officials adjudicate labor disputes. When tunnel workers die in the not infrequent “workplace accidents,” Hamas specifies how much the employers must pay the survivors -- usually between $12,000 and $20,000, depending on the worker’s age and number of children.

The main goal of the blockade, Israel says, is to prevent Hamas from importing weapons and dual-use material -- cement, for example, could be used to build bunkers, and pipes to manufacture rockets. The blockade’s secondary aim is to weaken Hamas by making life under its rule unpleasant for Gazans -- hence the bans on jam, cilantro, toys, and paper. Regardless, Gaza’s merchants can get virtually anything, even cars, through the tunnels. Diesel and gas flow through jerry-rigged pipelines. Vendors at Gaza’s markets sell essential goods such as tiles and cement, food staples such as sea bass and fresh oranges, and relative luxuries such as French yogurt and the Swiss toothbrushes that I bought for a dollar each.

Nonetheless, Gaza is a depressing place. Almost nobody leaves, and most people do not work. The siege of Gaza might not look like the siege of Stalingrad, but a siege it is. The tunnels still do not solve the fundamental problems of the blockade, including the absence of the supplies and machinery necessary to repair Gaza’s worn and war-shattered infrastructure (such as its sewage treatment system, power plants, and schools, to name a few of the top priorities cited by the United Nations). But they have solved Hamas’ short-term problem: staving off the popular rage that seethed during the blockade’s peak.

The tunnels are also the best illustration of how Hamas has learned to govern. Along the way to creating a new class of siege millionaires, it experimented with and discarded many approaches: firing rockets, adhering to a cease-fire, bringing millions in cash from Arab capitals in briefcases, railing against Israel, and partnering with smugglers. Finally, it legalized the tunnel economy. Since Israel has claimed that it will end the Gaza blockade only if Hamas surrenders power, the movement has been willing to improvise and embrace whatever works -- a merchant’s approach of finding the best deal and then justifying it retroactively.

Hamas has applied the same formula to its diplomatic strategy. It has hedged its bets, alternately hectoring and wooing Egypt, cozying up to Iran and Turkey, and shaming the Gulf petro-states into giving it money and political cover. In January, Gaza’s prime minister, Ismail Haniyeh, chastised Egypt from the minbar at Friday prayers in Gaza City for “losing its compass” and joining the ranks of those who “criminalize the resistance.” The Arabs, he argued, must draw close to Turkey: “We are working to build a new balance against the Israelis in the region.”

Since the 2006 elections, Hamas’ brain trust has been trying to plot a path out of global isolation. Ahmed Yousef leads the effort, drawing on his experience running an Islamic think tank in what he calls the “paradise” of Washington, D.C., for more than a decade. The number-two official in Hamas’ foreign ministry in Gaza, he is at once a consummate politician and a fierce defender of Hamas’ resistance ideology. He may be a conciliator, but he is no moderate.

“We want the West to understand it can do business with us,” he told me in January during a long conversation in his Gaza City office. “They want to know if we are more like the Taliban or like [Turkey’s Islamist prime minister, Recep Tayyip] Erdogan. They will see that we are closer to Erdogan. We are flexible.”

Diplomatically, Hamas has cast a wide net. The group has launched Web sites in English and Turkish and has dispatched senior officials to meet with any influential Westerners willing to talk, in public or in secret. Now, Hamas is benefiting from the results of its diplomatic groundwork. The flotilla that it did not organize has played right to Hamas’ strategy, earning it a spate of attention and summoning international pressure on Israel to loosen the blockade.

In the waning years of the Bush administration, Yousef contends, the White House sent “track two” emissaries to find out if Hamas was willing to change its ways. It was not, but Hamas officials were deeply interested in continuing a dialogue with Washington. More recently, Hamas passed a letter to the White House by hiding it in U.S. Senator John Kerry’s UN briefing packet. And last June, a group of former senior U.S. diplomats joined European officials at a two-day meeting with Hamas leaders in Zurich. Such contacts have continued, sources familiar with the talks have told me.

“These are the players on our playground. We are there, ready to deal,” Yousef said. “We would like to be engaged. We are willing to sit and talk. We want to be part of a peaceful attempt to settle the conflict.” Whether or not he is sincere, both Israel and the United States distrust Hamas’ overtures, in large part because the movement refuses to repudiate violence, including attacks on civilians.

Using a combination of guile, violence, and diplomacy, Hamas believes it can implement its own roadmap to an enduring cease-fire (which is its goal, it should be said, as opposed to “peace”). First in this plan, Hamas wants to expand the circle of countries that support it and chip away at the bloc opposing it. Turkey so far has proved the most responsive.

Second, it wants to reconcile with Egypt, which seems to loathe Hamas as much as Israel does, mostly because of the internal threat the country faces from Hamas’ parent group, the Muslim Brotherhood. Third, it wants to rejoin the Palestinian Authority on equal or superior terms to Fatah, which it defeated in the 2006 elections. Fourth, Hamas wants to begin talks with Israel based on the equilibrium that prevailed before the most recent Gaza war: a temporary truce that would allow the two sides to discuss a lasting cessation of hostilities and a return to the 1967 borders. Hamas’ long-term strategy does not aim for a final resolution but rather an indefinite cease-fire, with two neighbors living in a grudging coexistence (much as, say, Israel and Lebanon do today).

Hamas has defied the expectations of policymakers in Israel and the United States, first by digging its way out of economic ruin with the surprisingly resilient tunnel economy, then by diverting attention from its dark and violent side during the current unraveling of the consensus for a complete Hamas boycott. In both cases, Hamas went around and through the problem rather than confronting it head-on. For the time being, Hamas has survived without dealing with its own vulnerabilities, including its anti-Semitic charter, its disregard for the laws of war, and its propensity for authoritarianism. As Israel and the United States are beginning to learn, Hamas is a strategic actor that, for all its rough edges, knows how to engage in diplomacy. Its goals might be as belligerent as ever, but its tactics are increasingly pragmatic and effective. Washington and Israel might choose not to deal with Hamas, but Hamas is dealing with them.