Donald Trump has both consistently criticized NATO, and also member states that has refused to take part or condone US military actions in Iran. Particularly Spain has been directly opposed to the way, and recently an email circulating inside the Pentagon suggested, that the US could seek to expel Spain from NATO.
But that appears to have no legal basis, that's been confirmed by a NATO official to the BBC.
More specifically, the official stated that the founding treaty "does not foresee any provision for suspension of Nato membership, or expulsion", meaning that the US has no legal merit or basis to demand the expulsion of other NATO members, regardless of stance on military actions in Iran.
Spain has been one of the more critical voices of Trump's war, for instance refusing to let the US use Spanish air bases on its territory for attacks on Iran, such as Naval Station Rota and Morón Air Base.
Regarding the Pentagon email, Pedro Sánchez said this to reporters:
"We do not work based on emails. We work with official documents and official positions taken, in this case, by the government of the United States. Spain is in full cooperation with its allies, but always within the framework of international law."