President Trump fired John R. Bolton, his third national security adviser, on Tuesday amid fundamental disagreements over how to handle major foreign policy challenges like Iran, North Korea and Afghanistan.

His departure comes as Mr. Trump is pursuing diplomatic openings with two of the United States’ most intractable enemies, efforts that have troubled hard-liners in the administration, like Mr. Bolton, who view North Korea and Iran as profoundly untrustworthy.