The two leaders reiterated that their two countries should form a united front against their opponents.
President Bashar al-Assad emphasised terrorism in his comments after arriving in Tehran on Sunday for a two-day visit. "Iran and Syria should pay attention to terrorism, which is spreading in the Middle East," al-Assad said.
Both Iran and Syria are under pressure and facing sanctions from the United States. Washington accuses them of supporting militant groups such as Lebanon's Hizb Allah and radical Palestinian factions.
The United States says Syria is not doing enough to stop fighters crossing into Iraq to join the insurgency. It accuses Iran of seeking to build nuclear weapons under cover of a nuclear energy programme.
"Common threats deserve the formation of a united front by Iran and Syria more than ever," Aljazeera quoted Ahmadinejad as saying at a joint press conference with al-Assad.
"Common threats deserve the formation of a united front by Iran and Syria more than ever"
"Boosting relations could protect the region from the threats," he added.
The Iranian leader did not identify the source of the threats but in a commentary on the visit, Iranian state television commented: "Cooperation between the two countries is important, because the United States and Israel have invaded the region."
In February, during a visit by Syrian Prime Minister Naji al-Otari to Tehran, Iranian and Syrian officials had spoken of forming a united front to counter external pressure.
Countering US pressure
But nothing concrete about such an alliance has emerged. The Iranian TV commentary added: "Syria considers boosting relations as a way of reducing US pressure on Damascus."
Ahmadinejad, who was sworn in on Saturday, described al-Assad, 39, as the youngest and most intelligent Arab head of state, reported Iran's official Islamic Republic News Agency.
A united front is meant to
counter US pressure
Iran and Syria have long been close. Sunday's was al-Assad's fourth visit to Iran since he took office in 2000. During the 1980-1988 Iran-Iraq war, Syria was the only Arab country to support Iran.
During the past 10 years, Iranian companies have invested more than $700 million in Syria in sectors such as power generation, cars, cement and agriculture, the Islamic Republic News Agency reported.