According to the American Fuel and Petrochemical Manufacturers, diesel fuel is refined from crude oil through the use of a distillation column, making use of the varying boiling points of all the various chemicals in crude oil to separate products from the crude oil mixture. Diesel fuel is then further refined to remove pollutants in order to achieve the cleaner-burning low-sulphur diesel used commercially.
As stated by the AFPM, crude oil contains many different petrochemicals, each with their own unique uses and characteristics. Each of these chemicals also has its own unique boiling point. Refineries take advantage of the boiling point difference to separate out individual petrochemicals from the crude mixture. The crude oil is placed in a distillation column, and then heated to allow more volatile petrochemicals to boil off while the remaining chemicals remain in liquid form. Propane and gasoline are boiled off and collected first, followed by diesel, lubricating oil and other products. The diesel collected at this stage is fairly cheap, but it's full of sulphur and other pollutants. Once extracted, this diesel is further distilled and refined to reduce these potential pollutants. The resulting refined low-sulphur diesel burns much cleaner, but it's also much more expensive.