* Blast set off fire at 315,000 bpd Tula refinery
* Output not affected, says state oil company Pemex (Adds details on visbreaker)
By Cyntia Barrera Diaz and Mica Rosenberg
MEXICO CITY, July 30 (Reuters) - An explosion ripped through Mexico's second-largest oil refinery on Saturday, causing a massive fire and killing two workers, though production was not affected, state oil monopoly Pemex said.
The explosion occurred at the 315,000 barrel-per-day Tula refinery in central Mexico while the company was running a trial of a visbreaker, a unit used to reduce viscosity when distilling crude oil, a Pemex spokesman said.
The visbreaker, one of several at the refinery, recently underwent maintenance work and Pemex workers were testing it on Saturday to restart the unit, the spokesman said.
When a visbreaker fails, refineries end up with excessive fuel oil inventories that could hamper operations.
One worker was taken to hospital with serious injuries caused by the blaze, which was brought under control within an hour, Pemex said in a statement.
"The accident occurred in a small, very localized area, and so the refining production process was not affected," the statement said. "Operations are continuing normally." Pemex said it is investigating the cause of the accident.
Factbox on Pemex refining operations [ID:nN09229970]
The number of injured could be higher and a helicopter was being used to airlift workers needing medical attention, said Miguel Garcia, emergency services director for Hidalgo state.
Pemex employees were evacuated from the refinery but the fire posed no risk to the surrounding area, Garcia said.
Clouds of black smoke were seen billowing out of the refinery in pictures taken by residents near the blast and posted on the social networking site Twitter.
Mexico imports about 40 percent of its gasoline because of a lack of refining infrastructure in the oil producing nation. The country imported 674,500 barrels per day of fuel in June, according to Pemex data.
There are only six refineries in Mexico and serious accidents in the past have lead to a spike in imports or gasoline and diesel prices.
In September of last year an explosion killed one worker at Pemex's Cadereyta refinery in northern Mexico, Mexico's third largest oil processing facility.
That incident forced Pemex to shut two units and reduce output at the refinery, which can process 275,000 barrels per day, causing U.S. oil product futures [O/R] to briefly jump. (Reporting by Cyntia Barrera Diaz and Mica Rosenberg; editing by Anthony Boadle) (firstname.lastname@example.org; +5255 5282-7161; Reuters Messaging: email@example.com)