By Hugh Sykes
BBC News, Baghdad
Mahmoud Ahmadinejad arrived in Iraq on Sunday for a two-day visit - the first such trip by an Iranian president.
The Iranian president's visit to Iraq poses severe security problems
Although he was invited by Iraqi President Jalal Talabani, it is a controversial and potentially divisive state visit, as well as a security challenge.
Many Sunni Arabs find it deeply objectionable that Iraqi hospitality is being offered to a man they suspect of covertly helping to finance and arm Shia militia groups.
Those groups have killed hundreds of Iraqis in gruesome attacks that often involve torture with electric drills.
One Sunni tribal leader believes the Iranian president is coming here "to organise more terrorist operations in Iraq".
The United States also believes Iran has helped Shia groups in Iraq - especially helping develop "shaped" or "explosively penetrating" rounds.
Iran regards the US as an occupation force in Iraq, and considers resistance to be legitimate
These are chillingly effective roadside bombs that launch molten metal when they are detonated; the force of the explosion propels the molten rounds at such high speed that they can penetrate military armour.
And just a day before the Iranian presidential visit, the US military said they had captured a man they described as a sniper instructor "trained in Iran".
They said he was also an expert in the design and use of those penetrating rounds.
But Iran regards the US as an occupation force in Iraq, and considers resistance to be legitimate.
Before leaving for Iraq, Mr Ahmadinejad laughed off American accusations of Iranian interference.
"Is it not funny that those with 160,000 forces in Iraq accuse us of interference?" he asked.
The president's visit is a complex security challenge.
Baghdad International Airport, where he arrived, is directly alongside the mostly American military airbase - and the Americans control the airspace.
However, it was thought an Iraqi air traffic controller would be on duty for the Iranian presidential plane.
The US military believes Iran has backed Shia militants
Visiting dignitaries usually head straight from Baghdad airport to the fortified Green Zone - in an American helicopter.
The BBC understands that the Iranian president was not offered this facility and a car journey along the seven-kilometre airport road into the city was the likeliest option.
Traffic on this road has often been ambushed and attacked - and along much of its length there is only a light fence.
The president will also avoid the Green Zone, as to gain access to this area - home to the huge American Embassy and numerous Iraqi government offices - vehicles are required to stop at US checkpoints.
And few American troops would want to wave through a man many in the US believe was one of the students who kidnapped American diplomats in Teheran for 444 days soon after the fall of the Shah in 1979.
Mahmoud Ahmadinejad denies he was involved.
There are also paradoxes associated with this visit.
Despite decades of bad blood, Iran is a potential US ally - against al-Qaeda and the Taleban in Afghanistan.
Shia Iran has little in common with the fundamentalist Wahhabists of the Taleban and al-Qaeda.
After the attacks on New York and Washington in September 2001, Iranian Supreme Leader Ayatollah Ali Khamenei said he was "repulsed" by the loss of civilian lives.
During the following fortnight there were several meetings in Geneva between Iranian and US officials.
According to diplomats, the Iranians urged the US to invade Afghanistan as soon as possible and to install a government to oppose the Taleban.
Tehran also promised $500m for the reconstruction of Afghanistan.
It was enlightened self-interest. Iran did not want to be sandwiched between two enemies - Saddam Hussein to the west and the Taleban to the east.
It is ironic that both threats to Iranian stability were removed... by the US.