Written by Zachary Keck.

In the face of the growing threat it faces from China, Vietnam is pursuing a shrewd diplomatic strategy that seeks to balance against Beijing while preserving as much autonomy as possible.

Traditional international relations theory suggests that states facing a security threat will balance against that threat in one of two ways. The first is internal balancing—building up one’s own military forces in order to deter or defeat a challenge from a powerful neighbor. If possible, this form of balancing is preferable because it is the most reliable and allows states to retain their autonomy.

The second form of balancing is referred to as external balancing—states pursue alliances with other states that also perceive the powerful neighbor as a threat. External balancing is less desirable to states for two reasons. First, it is less reliable as there is no mechanism to ensure that an ally will come to one’s aid.

Second, alliances force states to surrender some of their autonomy albeit just how much depends on the nature of the alliance. In the worst case scenario, a state that forms a security alliance can become entrapped by an ally in a conflict in which it has no interest in fighting. But even if it avoids entrapment, the prospect of surrendering any autonomy can be a particularly unattractive option for a country like Vietnam which has a long history of colonialism.

Not surprisingly, then, Vietnam is taking some steps to balance internally by building up its armed forces. For example, between 2003 and 2011 Vietnam increased its defense budget by 82 percent. It is also seeking to mitigate tensions with China to the degree that this is possible. Indeed, last October Vietnam hosted Chinese Premier Li Keqiang for a state visit, and the two sides agreed to set up a working group on the South China Sea issue. In December government delegations held border talks.

Then, in January of this year, three Chinese navy ships docked in Ho Chi Minh City for a five day goodwill visit. During the same month, Chinese President Xi Jinping and Nguyen Phu Trong, general secretary of the Communist Party of Vietnam, vowed to deepen their bilateral comprehensive strategic cooperation. Clearly, then, Vietnam enjoys much more positive relations with China than countries like Japan and the Philippines.

Nonetheless, Hanoi recognizes that relying on Chinese goodwill alone is a losing strategy over the long run. It also understands that it cannot possibly balance against China through internal means alone. After all, China boasts a population that is over 15 times the size of Vietnam’s population; a GDP that is over 58 times larger, and, as of 2011, had a military budget that was almost 52 times the size of Vietnam’s.

Thus, Hanoi’s dilemma—which is not unlike the dilemma facing many middle powers—is to find a way to balance China through external means while preserving the greatest amount of its autonomy. It is achieving this by strengthening ties with as many major powers as possible, without becoming overly reliant on any one country.

In particular, it has been seeking to revive ties with Russia following a post-Soviet nadir in bilateral relations; taking important steps to overcome its historical animosities towards the U.S.; deepening ties with India on a number of fronts, much notably energy cooperation; and pushing for a greater consensus in ASEAN on the South China Sea issue, even as it strengthens bilateral relations with some of ASEAN’s maritime states that share its concern over China’s growing naval power. Recent years has also seen Vietnam and Japan strengthen ties, and Vietnamese President Truong Tan Sang will in fact be visiting Tokyo for three days next week.

Vietnam’s ability to strengthen ties with all these nations is made possible by a number of different factors. The first is simply the widespread concern in the region over China’s growing power and more assertive diplomatic posture. To some degree or another, China factors into all of the bilateral relations listed above. For some of them, notably Japan and the United States, China is arguably the dominant factor in the relationship.

The second factor is Vietnam’s prized geography and ability to harness these geography to make itself a valuable asset to its various partners. As Asia and particularly Southeast Asia’s economic potential grows, Vietnam’s central maritime real estate makes it important hub connecting different regions. As Stratfor, a private intelligence firm, has put it: “Vietnam is the pivot point of Southeast Asia, occupying a key position along the major corridors that connect the Strait of Malacca with the Northeast Asian economies, as well as those connecting the northeast to the smaller, dynamic economies to the south.”

Nearly as important, Vietnam has been careful to tailor the way it harnesses this geographical centrality to fit the needs of each particular partner. For example, given the prospect of a declining European market, Russia is hoping to greatly expand its oil and natural gas exports to Asia. While much of these will go to Northeast Asian nations, Vietnam can help Russia reach Southeast Asian markets because Vietnam is accessible by water from ports in Russia’s Far East region.

On the other hand, India has to contend with a growing appetite for energy imports that will only continue to increase for the foreseeable future. Thus, Vietnam has made joint energy exploration projects in the South China Sea the cornerstone of its bilateral relationship with India. This has the additional benefit of giving Delhi a larger stake in the outcome of China’s maritime disputes with its Southeast Asian nations.

For the United States and Japan, Vietnam offers an important potential inroad into ASEAN economic markets, and all three states are notably parties to the Trans-Pacific Partnership negotiations. For Washington especially, however, military access is a paramount concern. As a result of China’s growing precision strike missile capabilities, the U.S. is reorienting its military posture in the region to reduce its reliance on large permanent bases in places like Japan and South Korea, which China could destroy in a surprise strike or early on in a conflict. Instead, the U.S. is hoping to gain access to a larger number of more dispersed bases, as well as boost its ability to project power in the South China Sea.

Regaining access to Vietnam’s Cam Ranh Bay naval base is thus an attractive prospect for the United States, and Washington has courted Hanoi accordingly. For example, U.S. Secretaries of Defense and State have made numerous trips to Vietnam throughout the Obama administration, and last year President Obama hosted President Truong Tan Sang at the White House. During this latter meeting Washington and Hanoi established a comprehensive partnership, elevating bilateral relations to the next level.

The benefits for Vietnam of pursuing stronger ties with such a diverse group of nations should be obvious. By not becoming overly dependent on one nation, Hanoi doesn’t have to worry as much about the reliability of any single partner. Similarly, it can retain more of its autonomy, which is especially important for Vietnamese elites in light of the country’s history.

Zachary Keck is Associate Editor of The Diplomat where he authors The Pacific Realist blog. He also writes a monthly column for The National Interest. You can follow Zachary on Twitter @ZacharyKeck.