The Obama administration was preparing late last month to impose sanctions in response to Iran’s ballistic-missile tests but held off when Iranian officials warned the move would derail secret negotiations surrounding a prisoner swap, according to U.S. and congressional officials briefed on the exchange.

The U.S. imposed those sanctions on Sunday, after four of five U.S. citizens who had been held by Iran were freed and had left the country in the elaborate exchange, which coincided with the completion this weekend of the...