The US secretary of state, John Kerry, has said the Vietnam war was the result of a “most profound failure of diplomatic insight and political vision” as he marked the 20th anniversary of diplomatic relations between the two countries.

Kerry on Friday extolled the virtues of reconciling with former enemies at the end of a five-nation tour of the Middle East and south-east Asia that has been dogged by domestic US debate over the Iran nuclear deal.

He lamented that discussions have often focused on the alleged necessity of conflict.

“Standing here today, I’m reminded of conversations I’ve had recently with people who talk almost casually about the prospect of war with one country or another. And I’m tempted to say: ‘You don’t have the first idea of what you’re talking about’,” Kerry told an audience of civic and business leaders in a speech at a Hanoi hotel.

“For sure, there are times when one may have no choice but to go to war, but it is never something to rush to or accept without exploring every other available option,” he said. “The war that took place here half a century ago divided each of our countries and stemmed from the most profound failure of diplomatic insight and political vision.”

The Vietnam war veteran did not mention Iran or the nuclear deal but he made clear that the American-Vietnamese experience of the past 60 years could serve as a model for others.

“Vietnam and our shared journey from conflict to friendship crosses my mind frequently as I grapple with complex challenges we face today,” he said.

“That we are standing here today celebrating 20 years of normalised relations is proof that we are not doomed merely to repeat the mistakes we have made in the past. We have the ability to overcome great bitterness and to substitute trust for suspicion and replace enmity with respect.”

“The United States and Vietnam have again proven that former adversaries really can become partners, even in the complex world we face today. And as much as that achievement matters to us, it is also a profound and timely lesson to the rest of the world,” Kerry said.

Despite the resumption of ties and a surge in US-Vietnam trade, education and cultural exchanges over the past two decades, the US remains concerned about Vietnam’s human rights record. Kerry said Vietnam would not reach its full potential nor enjoy the fullest partnership possible with the US unless it improved rights conditions.

“The United States recognises that only the Vietnamese people can determine their political system and we speak with some humility on these matters, because as you can read and see, we are working hard to perfect our own system,” he said.

“But there are basic principles we will defend: no one should be punished for speaking their mind so long as they are peaceful; and if trading goods flow freely between us, so should information and ideas. And we believe that progress in upholding these basic human rights will absolutely serve Vietnam’s interests.”

If Vietnam expects to benefit from the protections of international rules and regulations it must also uphold international standards, Kerry said.

Kerry also encouraged Vietnam to adopt a Pacific Rim trade pact being negotiated and he reiterated the US commitment to helping the country protect and patrol its territorial waters.

The Obama administration in 2014 partially lifted a ban on arms sales to Vietnam, allowing the US to supply Hanoi with Coast Guard craft and associated equipment.

US officials said Washington was exploring other ways to assist Vietnam in bolstering its maritime law enforcement capabilities but that any further easing of arms restrictions would not happen until there were significant human rights improvements.

Despite the rights concerns, US officials see stronger ties with Vietnam as a linchpin in Obama’s policy in Asia. Vietnam is among the south-east Asian nations with competing claims with China over areas of the South China Sea, and has sought US support for negotiated resolutions to the disputes.

Kerry came to Vietnam from a regional security forum in Malaysia where he and China’s foreign minister clashed over who was to blame for rising tensions in the South China Sea, home to some of the world’s busiest commercial sea lanes.

The US and China’s smaller neighbours such as Vietnam are calling for a halt to massive Chinese land reclamation projects in the disputed areas over which Beijing claims sole sovereignty. Beijing rejects what it says is outside interference from Washington.

Kerry’s trip to Hanoi follows the first-ever visit to Washington of the head of Vietnam’s ruling Communist party, Nguyen Phu Trong, in July. He used the occasion to say that differences with the US on human rights should not be allowed to obstruct the deepening of relations.

Associated Press contributed to this report