America’s top defense official traveled to Cam Ranh Bay on Sunday, a symbolic return to what was a vital naval base for the United States during the Vietnam War.

Leon E. Panetta’s visit to the bay — the first by a U.S. secretary of defense in more than three decades — was intended to highlight a deepening partnership between the United States and its former foe as both seek to counter the growing influence and military assertiveness of China.

“We’ve come a long way, particularly with regards to our defense relationship,” Panetta said, noting that “a great deal of blood was spilled in this war on all sides — by Americans and by Vietnamese.”

For the Obama administration, which is attempting to reorient its foreign policy and military toward Asia in part because of China’s rise, Vietnam represents a key opportunity.

Despite long-standing efforts by China to forge ties with Vietnam’s communist government, leaders in Hanoi are increasingly turning elsewhere for new partnerships, most notably with the United States.

“This is a country that’s clearly thinking very strategically about China and its place in Asia,’’ said Ernie Bower, a Southeast Asia expert at the Center for Strategic and International Studies in Washington. “And Vietnam has turned out to be one of the more straight shooters. They call it like they see it on China. That’s something attractive to the U.S.”

Panetta’s stopover at Cam Rahn Bay was just the latest move on both sides to draw closer militarily.

The two countries signed a general agreement last year for defense cooperation, and during his two-day stay Panetta will work on the details of implementing that agreement with the defense minister and other top Vietnamese leaders.

The hope is that military cooperation will advance to the point where Vietnam would provide a key military access point and possibly even host a rotation of U.S. troops and Navy warships— a new approach the United States is adopting in Australia and Singapore and looking to implement in the Philippines.

Such arrangements are seen by defense leaders as a way to project American power at a lower cost and impose a lighter American footprint in countries where more permanent methods, such as a U.S. military base, would not be welcome.

There are signs Vietnam may be ripe for such an arrangement in coming years; since 2003, 20 U.S. Navy ships have been allowed stops in Vietnam.

But like many Southeast Asian countries that have clamored of late for an increased U.S. presence, Vietnam is at the same time moving cautiously into such a possible partnership to avoid provoking China, which remains a significant trading partner and has a much stronger military.

In Cam Ranh Bay, for example, Vietnam has begun in the last few years to allow U.S. Navy supply ships to dock for repairs and maintenance. Panetta toured one such ship on Sunday.

But Vietnam also has been careful to emphasize its “friends to all countries” policy, giving equal access to other countries as well.

Analysts with frequent contact with Vietnamese military leaders say there remain doubters about the budding U.S. relationship.

“Both sides are trying to avoid overplaying on the military cooperation aspect,” Bower said, “and this visit to Cam Ranh Bay is right on the edge of that calculation.”

As one of the best natural harbors in the area, the bay has long held strategic importance for many countries.

For the United States, it served as a logistics hub and an air base during the Vietnam War. Even after the American withdrawal, the Vietnamese leased the area for several years to the Soviet Union. Now, Vietnamese leaders want to turn it into a commercial port, servicing passing ships.

But one reason it is particularly appealing militarily is that it provides direct access to the South China Sea, a large swath of disputed territory that has created enormous friction in recent months between China and its neighbors, including Vietnam.

The bay also could prove particularly useful to the United States given a new strategy announced by Panetta on Saturday at a security conference in Singapore. In a speech to defense leaders from 28 countries, Panetta vowed that by 2020, 60 percent of the U.S. naval forces will be shifted into the Pacific and 40 percent in the Atlantic, in contrast to the current 50-50 split.

“Access for U.S. naval ships into this facility is a key component of this relationship and we see a tremendous potential here,” Panetta said.