Donald Trump's most senior counterterrorism official has resigned, saying he "cannot in good conscience" support the Iran war and claiming the country posed "no imminent threat" to the United States.