Democrats and a handful of Republicans backed a measure challenging Trump's handling of the conflict with Iran.