It would also embarrass France, Germany and the United Kingdom, the three European signatories to the nuclear deal, as they have been trying to salvage the agreement despite new U.S. sanctions against Tehran.
According to three Iranian officials, two Iraqi intelligence sources and two Western intelligence sources, Iran has transferred short-range ballistic missiles to allies in Iraq over the last few months. Five of the officials said it was helping those groups to start making their own.
"The logic was to have a backup plan if Iran was attacked," one senior Iranian official told Reuters. "The number of missiles is not high, just a couple of dozen, but it can be increased if necessary."
Iran has previously said its ballistic missile activities are purely defensive in nature. Iranian officials declined to comment when asked about the latest moves.
The Iraqi government and military both declined to comment.
The Zelzal, Fateh-110 and Zolfaqar missiles in question have ranges of about 200 km to 700 km, putting Saudi Arabia's capital Riyadh or the Israeli city of Tel Aviv within striking distance if the weapons were deployed in southern or western Iraq.
The Quds Force, the overseas arm of Iran's powerful Islamic Revolutionary Guard Corps (IRGC), has bases in both those areas. Quds Force commander Qassem Soleimani is overseeing the programme, three of the sources said.
Western countries have already accused Iran of transferring missiles and technology to Syria and other allies of Tehran, such as Houthi rebels in Yemen and Lebanon's Hezbollah.
Iran's Sunni Muslim Gulf neighbours and its arch-enemy Israel have expressed concerns about Tehran's regional activities, seeing it as a threat to their security.
Israeli officials did not immediately respond to requests for comment about the missile transfers.
Israeli Prime Minister Benjamin Netanyahu said on Wednesday that anybody that threatened to wipe Israel out "would put themselves in a similar danger".