South Korea would be within its rights to retaliate if North Korea mounts an attack, U.S. Defense Secretary Robert Gates said Thursday, but the United States wants Seoul and its neighbors to try to head off a North Korean provocation that could lead to war.

The United States fears that the risk of war is rising between U.S. ally South Korea and the heavily militarized and increasingly unpredictable regime in North Korea, which the Pentagon also considers a looming threat to the mainland United States.

"It's a long-standing principle that every country has the right to protect itself and defend itself against an unprovoked attack," Gates said following discussions with Japanese political leaders keyed to the rising threat of war on the Korean peninsula.

Earlier this week Gates lobbied China to pressure the North not to go too far. Gates will go to South Korea on Friday for a quick and hastily arranged crisis session about the North.

Gates was urging patience while China, which props up the fellow communist state, tries to persuade North Korea to avoid a military provocation that South Korea would feel bound to answer.

The North twice shocked the South last year, allegedly sinking a South Korean warship in March, killing 46, and then shelling front-line Yeonpyeong Island in November, killing four. The island sits in waters the North claims as its own.

"The objective that we all have in common is how do we prevent another provocation from taking place?" Gates said.

Japanese Defense Minister Toshimi Kitazawa condemned "wanton" aggression by the North and said Japan fully supports South Korea.

The top U.S. military officer, Joint Chiefs of Staff Chairman Mike Mullen, said North Korea poses "an evolving threat, not just to the region but to the United States specifically."

Mullen, speaking at the Foreign Press Center in Washington, urged coordinated pressure among China, Russia, South Korea and Japan, which are considered the nations with disarmament leverage and the most at stake.

The capability to strike beyond North Korean shores "is becoming more and more dangerous," Mullen said Wednesday.

Earlier this week, Gates laid out a twofold worry: The South Korean public is fed up after two deadly attacks blamed on the North last year and wants its government to fight back, and the North is developing nuclear weapons it could aim at the U.S.

"With the North Koreans' continuing development of nuclear weapons and their development of intercontinental ballistic missiles, North Korea is becoming a direct threat to the United States, and we have to take that into account," he said during a visit to China.

South Korea and Japan held military talks Monday on accords to share intelligence and provide each other with fuel and medical support, officials said, in a sign of the growing worry about the North.

Seoul and Tokyo are important trading and diplomatic partners, but the possibility of such a military pact is a sensitive topic in South Korea, because of Japan's brutal 35-year occupation of the Korean peninsula that ended in 1945. The accords would be the two nations' first military agreement since then.

The two Koreas restored an important cross-border communication channel on Wednesday, though South Korea still rejected North Korea's calls for talks meant to defuse high tensions.