MADRID — Spain closed its airspace to U.S. military planes involved in the Iran war, officials said Monday. The NATO member also said that the U.S. could not use jointly operated military bases for operations related to the Iran war, officials said earlier.

Defense Minister Margarita Robles confirmed the restrictions in explicit terms. "This was made perfectly clear to the American military and forces from the very beginning. Therefore, neither the bases are authorized, nor, of course, is the use of Spanish airspace authorized for any actions related to the war in Iran," Robles said.

Prime Minister Pedro Sánchez described the Iran war as illegal, reckless and unjust. "You cannot respond to one illegality with another, because that's how humanity's great disasters begin," Sánchez said.

The prime minister called on the U.S., Israel and Iran to end the war. Robles described the Iran conflict as profoundly illegal and profoundly unjust.

After Sánchez's government denied U.S. use of the Rota and Morón military bases in southern Spain, President Donald Trump threatened to cut trade with Madrid. U.S. Secretary of State Marco Rubio said that Spain's leaders are bragging about cutting off Spanish airspace while the U.S. remains committed to defending the NATO member.

"It allows us to station troops and aircraft and weapons in parts of the world that we wouldn't normally have bases, and that includes in much of Europe," Rubio told Al Jazeera. "But if NATO is just about us defending Europe if they're attacked, but then denying us basing rights when we need them, that's not a very good arrangement."

Spain has been a vocal critic of U.S. and Israeli military actions in the Iran conflict. NATO did not comment on Spain's decision, referring questions to national authorities, NATO said.

NATO members have previously denied airspace access during military operations. In 1986, France and Italy blocked the U.S. military from using their airspace for an operation targeting Libyan leader Moammar Gadhafi.

In 2003, NATO member Turkey refused to allow American troops to use its territory to invade Iraq, though it allowed overflights. France and Germany opposed the Iraq war but allowed U.S. and British fighter jets to fly over their airspace.