Mr Ahmadinejad called on the international community to take action to prevent what he called a brewing and dangerous storm.
He warned that the conflict could spread throughout the region.
Mr Ahmadinejad has been visiting the Central Asian republic to expand cultural ties between the countries.
But during a joint press conference the Iranian leader and his host focused on the Middle East.
Mr Ahmadinejad said solving problems with bombardments and occupation was unacceptable and that the actions of those attacking Lebanon would seriously backfire.
As the Iranian president spoke, his host nodded in agreement.
The languages the two men speak – Farsi and Tajik – are very similar and this was the basis, the presidents said, for Iran’s expanding cooperation with Tajikistan.
The two leaders have signed several new agreements, an indication they say of a growing relationship.
And with it the distance between Tajikistan and its once close ally – the US – seems to be growing too.
Tajikistan played an important role when Washington went to war with Afghanistan, just across the border.
But recently Tajikistan began turning towards Iran and Russia. Moscow has a permanent military base here now, and Tehran is one of the largest investors.
It is not that Tajikistan has much to offer in return – it is Central Asia’s poorest country with hardly any natural resources.
But what it does have is a strategic location along the ancient Silk Route.
There are also ties of language and history between it and Iran, which have come to the fore.
Tajik officials say they support not just Iran’s stance on the Middle East, but its right to develop nuclear technology.
And so while the pressure from the West on Iran is high, during his talks in the Tajik capital, Dushanbe, Mr Ahmadinejad was among friends.