Defense Secretary Robert Gates gently chided Vietnam for its blemished human rights record Monday but marveled at the friendly ties the U.S. has built with Vietnam a generation after the Vietnam War.

Gates addressed a university audience in Hanoi, not far from the lake where Sen. John McCain famously crashed his war plane and became one of the best-known prisoners of war. The defense secretary is in Vietnam to attend an Asian security ministers meeting Tuesday as well as to meet with delegates from some of the small nations that want U.S. support to counter the growth of China as a regional power.

The room was full of students born after the war and reared on Vietnam's blend of communism and capitalism.

"While we do not and will not always agree, it is critical that we remain willing to discuss these differences, for example on human rights issues, candidly," Gates said.

Vietnam has jailed political opponents. It circumscribes freedom of speech, press freedom and freedom of assembly. The United States has called the overall record poor, although it is better than some of Vietnam's neighbors.

In an indirect warning to China, Gates said Asian territorial disputes should be resolved through international diplomacy. Vietnam is one of several Southeast Asian nations arguing with their much larger neighbor China about ownership of strategic island chains and access to international waters.

Nerves have been rattled across the region following a series of aggressive moves by China on the high seas. The latest spat erupted last month with Japan over a collision between a Chinese trawler and two Japanese patrol boats off islands in the East China Sea claimed by both countries. The Japanese Defense Minister met with his Chinese counterpart in Hanoi on Monday, Kyodo New Agency reported.

Gates is in Vietnam largely to make the point that the US will back small nations that feel pushed around by China. He is trying at the same time to mend military ties between the US and China that fell apart this year following the proposed U.S. arms sales to China's rival Taiwan worth more than $6 billion.

Gates was meeting a Chinese counterpart, Liang Guanglie, later Monday.

The U.S. wants the territorial fights settled peacefully and with input from other countries that have an interest in the Pacific region. The U.S. considers itself such a nation although Gates did not make that point directly in his address at Vietnam National University. China views that as meddling.

"The U.S. and Vietnam, as well as other nations in the region, also share a common interest in maritime security and freedom of access to the global commons," Gates told the university audience.

That was a reference to China's claim to control waters the U.S. considers open to all.

In the run-up to their meeting defense ministers also stressed the need for more dialogue to ease regional tensions.

Gates met later with Vietnam's defense chief. Gates was greeted outside the building by goose-stepping Vietnamese soldiers and a marching band that played first the U.S., then Vietnamese national anthems.

Defense Minister Gen. Phung Quang Thanh said the two discussed widening cooperation for the recovery of both U.S. and Vietnamese war dead. Thanh said Vietnam will consider allowing the U.S. to join Vietnamese searchers at six sensitive military sites that have been off-limits.

Gates told reporters afterward that the subject of Southeast Asian territorial quarrels with China did not come up, but he repeated the U.S. view that those disputes should be handled peacefully, through negotiation or arbitration.

Gates' university audience clapped politely as he was introduced to the thumping beat of electronic dance music. Questions were polite, too, and apparently scripted in advance.

One student asked whether the U.S. would walk away from its obligations in Asia. Gates assured him no.

Asked about his own retirement plans, Gates was coy.

"We'll see," he said.

Gates is expected to leave his post next year, probably in the spring.