South Korea’s Foreign Ministry said the test, the first by the North this year, demonstrated the “maniacal obsession” of the North Korean leader, Kim Jong-un, with developing a nuclear-tipped ballistic missile.

The test came less than two days after Mr. Trump said on Friday that defending against the nuclear and missile threats from North Korea was a “very, very high priority.” Mr. Trump made the comment at a news conference with Mr. Abe at the White House. In their joint statement, the two leaders had urged North Korea “to abandon its nuclear and ballistic missile programs and not to take any further provocative actions.”

The test of an intercontinental-range system would have been especially provocative because it would mean that North Korea was trying to develop the ability to strike the United States. South Korean officials said they believed that the North has been using the Musudan, its intermediate-range missile, to develop and test some intercontinental ballistic missile, or ICBM, technologies.

North Korea has deployed and often tested short-range Scud and midrange Rodong ballistic missiles that can reach most of South Korea and Japan, but it has had a spotty record in test-launching the Musudan, its only missile with a range long enough to reach American military bases in the Pacific, including those on Guam. North Korea’s last Musudan test ended in failure in October.

In a New Year’s Day speech, Mr. Kim said his country had reached a “final stage” in preparing to conduct its first test of an ICBM. That drew a Twitter post the next day from Mr. Trump that said, “It won’t happen!”

North Korea has since warned that it could test-launch an ICBM “anytime and anywhere,” in its first challenge to the new American president.

The American defense secretary, Jim Mattis, visited South Korea on his first official trip abroad and agreed with South Korea to boost the allies’ joint defense abilities against North Korea. The two allies also agreed to push ahead with their plan to deploy an advanced American missile defense system known as Thaad in South Korea by the end of the year, despite a strong protest from China.