The blast happened in the southwestern city of Abadan. The president was scheduled to inaugurate an expansion project at a 400,000 barrel per day refinery.
Iranian media reported a gas leakage caused the blast. Up to two people were killed and at least 20 people were injured. Firefighters quickly extinguished a fire caused by the explosion, but the extent of the damage was not immediately clear.
/*Ahmadinejad*/ himself was not injured. A news agency said that the president ordered a special plane to airlift those critically injured to Tehran.
There are conflicting reports on the timing. One report has the blast happening right before the president's visit and another says it happened after.
During his speech shown on state TV from Abadan, Ahmadinejad appeared unperturbed about the blast and assailed the country's enemies, telling local officials that Iran is able to meet all its domestic oil needs.
"The hopes of Iran's enemies in imposing pressure through restrictions on the sale of oil products have turned into a complete disappointment," Ahmadinejad said.
The expansion at the Abadan plant is aimed at increasing capacity by about 30 percent at the century-old plant - the largest of Iran's nine refineries. The plant alone accounts for about 25 percent of Iran's fuel production, which is about 1.67 million barrels per day.
The Associated Press contributed to this story