After months of hit-and-run attacks on American forces in Iraq that pushed the United States and Iran to the brink of war in January, Iran has called off its proxy militias and the attacks have largely ceased.

When Iraq’s Parliament chose an American-backed prime minister this month, Iran, which has been instrumental in choosing previous Iraqi governments, ultimately acceded to the choice and helped put him in office.

In April, Iran reached out to the United States to open negotiations for a prisoner swap, offering to release a United States Navy veteran held by Iran in exchange for an Iranian-American doctor detained by the Americans.

Attacks on merchant ships and tankers in the Persian Gulf that threatened one of the world’s busiest shipping lanes for much of last year have been ratcheted down, although not entirely ended.