WASHINGTON — President Obama and Prime Minister Shinzo Abe of Japan have reached an accord to tighten defense cooperation and are pressing toward an agreement to tear down trade barriers between their two countries and across the Pacific Rim, as both leaders move to counter rising economic and military threats from China.

On the eve of a formal state visit by Mr. Abe to the White House, American and Japanese officials announced an agreement on Monday that would expand the reach of Japan’s military — now limited to its own defense — allowing it to act when the United States or countries American forces are defending are threatened.

The agreement reflects worries about North Korea and, especially, China, whose territorial claims in the South China Sea and growing military spending have upset its neighbors.

“With China’s growing assertiveness and North Korea’s nuclear and ballistic missile programs, Japan, like a lot of allies, wants to be there for us so we’ll be there for them,” said Michael J. Green, the senior vice president for Asia and Japan Chair at the Center for Strategic and International Studies. “It allows the U.S. military to plan Japan in, so that when we turn to them and say, ‘Can you deal with our left flank?,’ the Japanese, in principle, now can do that.”