The explosion took place at around 5:30 am (0330 GMT) in a site owned by the Bayernoil group near the Bavarian city of Ingolstadt, on the banks of the Danube river.
Nearly 600 firefighters, police and rescue workers were mobilised and were able to extinguish large parts of the fire by mid-afternoon, police said.
Public broadcaster Bayerischer Rundfunk had reported that the shockwaves from the blast were felt several kilometres away.
Pictures from the scene showed flames and smoke rising above the refinery as dawn broke.
All of the injured were employees at the refinery. Four were hospitalised, with one in a serious condition, police said in a statement.
Some 1,800 residents of the nearby towns of Vohburg and Irsching had been evacuated as a precaution.
But around four hours after the explosion, the density of the smoke above the site had diminished to an extent where rescue services allowed residents to return to their homes.
"The situation has eased a little. And the evacuation of the nearby residents is no longer necessary," said a police spokesman.
Emergency services had appealed to residents within a 20-kilometre (12-mile) radius to "keep their doors and windows closed because of the smoke".
Bayernoil employs 790 people at two sites in Bavaria and produces petrol, diesel and heating oil, as well as bitumen, with a crude oil processing capacity of 10.3 million tonnes a year, according to its website.
The most recent refinery fire in Germany occurred at a Shell plant in July, and caused no injuries.