The Iranian military on Tuesday seized a Western cargo ship in the Persian Gulf, the Pentagon said, roiling markets.