SEOUL, South Korea – In a first, North Korea on Tuesday fired a ballistic missile designed to carry a nuclear payload that flew over Japan and splashed into the northern Pacific Ocean, officials said. The aggressive missile launch – likely the longest ever from North Korea – over the territory of a close U.S. ally sends a clear message of defiance as Washington and Seoul conduct war games nearby.

In a statement, U.S. President Trump said North Korea had signaled its “contempt for its neighbors” and that “all options are on the table” in terms of a U.S. response.

South Korea’s Joint Chiefs of Staff said the missile traveled around 1,677 miles and reached a maximum height of 341 miles as it flew over the northern Japanese island of Hokkaido. The distance and type of missile tested seemed designed to show that North Korea can back up a threat to target the U.S. territory of Guam, if it chooses to do so, while also establishing a potentially dangerous precedent that could see future missiles flying over Japan.

Any new test worries Washington and its allies because it presumably puts North Korea a step closer to its goal of an arsenal of nuclear missiles that can reliably target the United States. Tuesday’s test, however, looks especially aggressive to Washington, Seoul and Tokyo.

North Korea has conducted launches at an unusually fast pace this year – 13 times, Seoul says – and some analysts believe it could have viable long-range nuclear missiles before the end of Trump’s first term in early 2021.

Seoul says that while North Korea has twice before fired rockets it said were carrying satellites over Japan – in 1998 and 2009 – it has never before used a ballistic missile, which is unambiguously designed for military strikes. North Korea also chose not to fire its most recent missile at a lofted angle, as it did in previous launches to avoid other countries, and Seoul’s spy service said the North launched from an unusual spot: the international airport in its capital, Pyongyang.

Some outside observers said launching a road-mobile missile from an airport runway could demonstrate the North’s ability to fire its missiles from anywhere in the country.

The South Korean military was analyzing whether North Korea had launched a Hwasong-12, a new intermediate-range missile that it recently threatened to fire into waters near Guam, which hosts a major U.S. military base that the North considers a threat.

The launch is also another rebuke to Trump, who suggested last week that his tough approach to North Korea, which included threats to unleash “fire and fury,” meant leader Kim Jong Un “is starting to respect us.”

Tuesday’s missile landed nowhere near Guam, but firing a Hwasong-12 so soon after the Guam threat may be a way for North Korea to show it could follow through if it chose to do so. Guam is 2,110 miles away from North Korea, but South Korea’s military said the North may have fired the most recent missile at a shorter range.

North Korea will no doubt be watching the world’s reaction to see if it can use Tuesday’s flight over Japan as a precedent for future launches.

Trump said in his statement that “Threatening and destabilizing actions only increase the North Korean regime’s isolation in the region and among all nations of the world,” and that “All options are on the table.”

Japanese officials made their usual strongly worded condemnations of the launch.

“We will do our utmost to protect people’s lives,” Japanese Prime Minister Shinzo Abe said. “This reckless act of launching a missile that flies over our country is an unprecedented, serious and important threat.”

The launch was also condemned by U.N. Secretary-General Antonio Guterres, Britain, France, Germany, Russia, and a number of other countries.

Tokyo said there was no reported damage from the missile. Residents on Hokkaido were warned of a North Korean missile launch by an alert on their cellphones, with loud alarms and an email that told people to stay indoors. Speakers broadcast an alert saying “missile is passing, missile is passing.”

Tuesday’s launch came days after North Korea fired what was assessed as three short-range ballistic missiles into the sea, and a month after its second test of an intercontinental ballistic missile, which analysts say could reach deep into the U.S. mainland when perfected.

In an unusual move, the military in Seoul released videos of three South Korean missile tests conducted last week. They showed two types of new missiles with ranges of 500 miles and 310 miles being fired from truck-mounted launchers.

South Korea’s Agency for Defense Development said the launches represented the last flight test for the longer-range missile before it is operationally deployed. Such missiles, which would be the latest additions to South Korea’s Hyumoo family of missiles, are considered key components of the so-called “kill chain” pre-emptive strike capability that South Korea is pursuing to counter North Korea’s nuclear and missile threat.

South Korea also said its air force conducted a live-fire drill involving four F-15 fighter jets dropping eight MK-84 bombs that accurately hit targets at a military field near the country’s eastern coast. Yoon Young-chan, chief press secretary of South Korean President Moon Jae-in, said the exercise was conducted after Moon directed the military to “display a strong capability to punish” North Korea if need be.

The North’s launch over Japan shouldn’t be a total surprise. Earlier this month, when threatening to lob four Hwasong-12s into the waters near Guam, North Korea specifically said they would fly over Japanese territory. North Korea in June also angrily reacted to the launch of a Japanese satellite it said was aimed at spying on the North and said Tokyo was no longer entitled to fault North Korea “no matter what it launches or whether that crosses the sky above Japan.”

North Korea typically reacts with anger to U.S.-South Korean military drills, which are happening now, often testing weapons and threatening Seoul and Washington in its state-controlled media. But animosity is higher than usual following threats traded between Trump and the North.

North Korea regularly says U.S.-South Korean military drills are a rehearsal for invasion, and North Korea’s U.N. ambassador, Ja Song Nam, wrote recently that the exercises are “provocative and aggressive” at a time when the Korean Peninsula is “like a time bomb.”

Associated Press writer Yuri Kageyama in Tokyo contributed to this report.