Oil refineries basically refine crude oil into petroleum products like gasoline, heating oils, and diesel. They function as the second stage in the production process after the actual extraction of oil rigs. Distillation is the first refining process where crude oil is heated at great temperatures to separate the different hydrocarbons.