Biodiesel-processing factories employing the alkali-catalyzed transesterification process generate a large amount of wastewater containing high amount of methanol, glycerol, and oil. As such, wastewater has high potential to produce biogas using anaerobic treatment. The aim of this research was to investigate the performance of an anaerobic baffled reactor for organic removal and biogas production from biodiesel wastewater. The effect of different organic loading rates, varying from 0.5 kg m-3 d-1 to 3.0 kg m-3 d-1 of chemical oxygen demand, was determined using three 22 L reactors, each comprising five separate compartments. Wastewater was pretreated with chemical coagulants to partially remove oil prior to experimentation. Results show that the anaerobic baffled reactor operated at 1.5 kg m-3 d-1 of chemical oxygen demand and ten days of hydraulic retention time provided the best removal efficiencies of 99 % of chemical oxygen demand, 100 % of methanol, and 100 % of glycerol. Increasing the organic loading rate over 1.5 kg m-3 d-1 of chemical oxygen demand led to excessive accumulation of volatile fatty acids thereby making the pH drop to a value unfavorable for methanogenesis. The biogas production rate was 12 L d-1 and the methane composition accounted for 64-74 %. Phase-separated characteristics revealed that the highest chemical oxygen demand removal percentage was achieved in the first compartment and the removal efficiency gradually decreased longitudinally. A scanning electron microscopic study indicated that the most predominant group of microorganisms residing on the external surface of the granular sludge was Methanosarcina. ? 2011 Institute of Chemistry, Slovak Academy of Sciences.