Chavez' two-day visit came as Iran faces renewed international criticism for its nuclear program and as a backer of Hezbollah guerrillas, engaged in fighting with Israel since they captured two Israeli soldiers July 12.
The five permanent members of the U.N. Security Council on Friday reached a deal on a resolution that would give Iran until the end of August to suspend uranium enrichment or face the threat of economic and diplomatic sanctions.
Following talks, Chavez pledged that his country would "stay by Iran at any time and under any condition," state television reported.
Ahmadinejad said he saw in Chavez a kindred spirit.
"I feel I have met a brother and trench mate after meeting Chavez," Ahmadinejad was quoted as saying by state-run television. "We think Iran and Venezuela should share all experiences of each other, stay by each other and they have to be supporters of each other."
The Venezuelan leader has been on a trip that included a visit to Belarus where he met with authoritarian President Alexander Lukashenko, who is dubbed "Europe's last dictator" by Washington and shares Chavez's strong anti-U.S. views.
Earlier this week he secured an arms agreement with Russia in Moscow that prompted the U.S. criticism.
While in Qatar on Friday, Chavez said it meant Venezuela could eventually export guns and ammunition to Bolivia and other allies once it opens a factory to make Russian-developed Kalashnikov rifles under license.
Chavez accused the United States of "threatening" to stop supplying replacement parts for the weapons to leftist Bolivian President Evo Morales' government. If the U.S. follows through, Chavez said, "we could supply Bolivia... and other friendly countries that also require a minimal level of defense."
"Maybe in the future we'll become an [arms] exporting country," Chavez said.
Bilateral trade last year between Iran and Venezuela was valued at approximately US$1 billion. Iranian investment in Venezuela includes a production line for tractors and several housing projects.
During his visit, Chavez was to inaugurate the new Venezuelan embassy in Tehran and meet Iranian business leaders. He was also to tour Iran-Khodro, Iran's giant public sector automobile manufacturer. The leaders and top officials were expected to sign memorandums of understanding in various fields.
Iranian state television reported that Chavez was also to meet Iran's Supreme Leader Ayatollah Ali Khamenei
"We do not have any limitation in cooperation," Ahmadinejad was quoted as saying. "Iran and Venezuela are next to each other and supporters of each other. Chavez is a source of a progressive and revolutionary current in South America and his stance in restricting imperialism is tangible."