The test was a direct challenge to Mr. Trump. Just last week, at a political rally in Arizona, Mr. Trump suggested that his threat to rain down “fire and fury” on North Korea if it endangered the United States was beginning to bear fruit. Kim Jong-un, the North Korean leader, was “starting to respect us,” Mr. Trump said.
Secretary of State Rex W. Tillerson had also cited a pause in testing by the North, saying he was “pleased to see that the regime in Pyongyang has certainly demonstrated some level of restraint that we have not seen in the past.” Mr. Tillerson suggested that it could be a “pathway” to dialogue.
Only days later, that optimism seemed premature when the North Koreans launched three short-range missiles on Saturday. Two of them traveled about 155 miles before splashing down, far enough to reach major South Korean and American military bases, including those about 60 miles south of Seoul.
While North Korea has not carried out its threat to fire four of its ballistic missiles toward the coast of Guam — and near an American air base — the missile it fired over Japan on Tuesday appeared to be of the same type: an intermediate-range missile that could target American, South Korean and Japanese bases in northeast Asia.
Only twice before has the North fired projectiles over Japanese territory: once in 1998, prompting a minor diplomatic crisis in Asia, and once again at the beginning of the Obama administration in 2009. In both those cases, the North said the rockets were carrying satellites into orbit. In this case, it made no such claim.
As in the case of the 2009 launch, which was paired with a nuclear weapons test, North Korea appears to be testing a new American president.
Notably, the missile fired on Tuesday took off from near Pyongyang, North Korea’s capital. Early reports, which are often corrected later, indicated it was launched from a site near Pyongyang’s international airport, not the usual launch site in the northeast, according to the South Korean military. They said they were still trying to determine what type of missile was launched.
American officials noted that if it was in fact launched from the capital’s outskirts, it may have been meant to complicate recent American threats to hit the North with pre-emptive strikes. That possibility was explicitly raised this month by Trump administration officials, as a way of seeking to deter the North Koreans.
While the North’s usual launch sites are in remote areas, where there would be little concern about civilian casualties, any strike near Pyongyang would risk many civilian deaths and would suggest the real goal was to strike at the regime.
An attack near Pyongyang would also be far more likely to result in North Korean retaliation against Seoul.
Lt. Gen. Hiroaki Maehara, the commander of the Japan Air Self-Defense Force’s Air Defense Command, said that the armed forces did not try to shoot down the missile from North Korea on Tuesday because they did not detect a threat to Japanese territory.
But when the government detected the launch and followed the path of the missile, it warned citizens in its path to take cover — just in case any parts fell on Japan.
According to Itsunori Onodera, Japan’s defense minister, the missile launched Tuesday was very likely a Hwasong 12, which is classified as intermediate range and is fired from mobile launchers. North Korea successfully tested a Hwasong 12 in May.
The North Korean missile tests on Saturday and again on Tuesday came during joint military drills that the United States and South Korea started a week ago. For the United States and South Korea, these drills — mostly conducted on computer screens — are normal exercises. But the North calls such annual drills a rehearsal for invasion and often lashes out with weapons trials and military exercises of its own.
The United States has also been conducting joint exercises with Japanese forces for the past two weeks, and it was Japan that seemed most directly affected by Tuesday’s launch.
Speaking on national television, Mr. Abe said his government “was prepared to take all the measures to protect people’s lives.”
“We have lodged a firm protest to North Korea. We have requested an urgent meeting of the U.N. Security Council,” he added. Diplomats said the meeting would most likely be Tuesday afternoon.
The Japanese government sent a text alert to citizens about the launch and advised them to take protective cover. In a post on Mr. Abe’s Twitter account, the government confirmed that the missile was fired at 5:58 a.m. local time, before breaking into three pieces and landing about 730 miles off the coast of Cape Erimo on Hokkaido, around 6:12 a.m.
Takaaki Uesugi, a security guard at the town hall of Erimo, on the southern tip of Hokkaido, said he first heard about the launch from an alert on his phone.
“I’m really worried about how America will react,” he said. “It’s possible that Japan could be dragged into a dangerous situation depending on how President Trump responds to this.”
A woman in Tokyo, Kaoru Kuroko, also said she had heard an alarm on her telephone soon after the missile was launched. “It was scary,” she said. “I wondered, where will the missile go to?”
South Korea said it was ready to defend itself from the North Korean threat. “North Korea must come to the negotiating table, realizing that denuclearization is its only way to ensure its security and economic development,” the South Korean Foreign Ministry said in a statement on Tuesday.
With China to the west and Russia to the north, North Korea can flight-test its mid- or intermediate-range missiles only to the south or to the east, analysts said.
“In a way, this was a hard choice to make for the North because it meant to fire the missile over Japan or toward Guam,” said Kim Yong-hyun, a professor of North Korean studies at Dongguk University in Seoul. “In the end, it chose to fire over Japan, demonstrating its capability to launch a missile to Guam but without actually launching one in that direction, which would have been a huge provocation to the United States.”
North Korea has conducted more than 80 missile tests since Mr. Kim came to power in late 2011, after the death of his father, but it has not sent any of those missiles over Japan.
Even when it flight-tested an intercontinental ballistic missile on July 28, it was launched at a highly lofted angle so that it reached an altitude of 2,300 miles. But it flew only 998 horizontal miles, falling in waters between the North and Japan. The North said at the time that it did so in order not to send its missile over a neighbor. Thus, the missile test on Tuesday was considered especially bold.
Along with South Korea, Japan and Guam would most likely be the first targets of a North Korean attack should war break out on the Korean Peninsula, analysts said. Both are home to major American military bases.