Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Iran has test-fired a medium-range ballistic missile, the first launch of its kind since President Donald Trump took office, according to two U.S. defense officials.

The United States deemed the launch to be a failure, after the missile flew more than 500 miles before crashing, according to the officials who spoke to NBC News on Monday on condition of anonymity because they were not authorized to speak with the press.

Iran shares a border with Syria, Pakistan and Afghanistan, among other countries. Google Maps

The test-fire poses a challenge for Trump's fledgling administration. During the campaign, he took several stances on the Iran nuclear deal signed by Barack Obama and other world powers in 2015, vowing to strictly police the agreement or renegotiate it entirely.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Iran used to be prohibited from test-firing ballistic missiles under previous U.N. resolutions. However, these were superseded by a new resolution passed alongside the nuclear deal.

This only "called upon" Iran not to test-fire missiles that could be used to deliver nuclear weapons. Critics of the deal say this wording is effectively a loophole meaning the missile-testing restrictions are not obligatory.

The government in Tehran says that because it doesn't have a nuclear-weapons program its missile tests are not violations of this clause.

Iranian Foreign Minister Javad Zarif didn't confirm or deny the launch during a press conference Tuesday but struck a defiant tone over the international restrictions.

"The missiles aren't part of the nuclear accords," he said, according to Reuters. "Iran will never use missiles produced in Iran to attack any other country."

Zarif added: "We're not going to wait for others' permission to defend ourselves ... Maybe the new government that has already shown its image internationally will use this against Iran to start new tension."

The U.S. and Israeli governments on Monday both accused Iran of test-firing the missile, with Israeli Prime Minister ‎Benjamin Netanyahu calling it a "flagrant violation of a U.N. Security Council resolution" and saying that "Iranian aggression must not go unanswered."

Meanwhile, White House Press Secretary Sean Spicer said he was "aware that Iran fired that missile" and that the Trump administration was "looking into the exact nature of it."

Iran was one of seven Muslim-majority countries whose citizens were subject to travel restrictions imposed by the Trump administration.