DUBAI (Reuters) - Iran has detected and removed malicious software from two of its petrochemical complexes, a senior military official said on Saturday, after announcing last week it was investigating whether recent petrochemical fires were caused by cyber attacks.

The official said the malware at the two plants was inactive and had not played a role in the fires.

"In periodical inspection of petrochemical units, a type of industrial malware was detected and the necessary defensive measures were taken," Gholamreza Jalali, head of Iran's civilian defense, was quoted as saying by the state news agency IRNA.

Iran is alert to the threat of cyber attack by foreign countries. The United States and Israel covertly sabotaged Iran's nuclear program in 2009 and 2010 with the now-famous Stuxnet computer virus, which destroyed Iranian centrifuges that were enriching uranium.

The National Cyberspace Council announced last week that it was investigating whether the recent petrochemical fires were triggered by a cyber attack.

But when asked if the fire at Iran's Bu Ali Sina refinery complex last month and other fires this month were caused by the newly-discovered malware, Jalali said: "the discovery of this industrial virus is not related to recent fires."

The oil minister said last week that most of the fires in petrochemical plants happened because the privatized petrochemical companies have cut their budgets for health and safety inspections.

(Reporting by Bozorgmehr Sharafedin; Editing by Ros Russell)