The present invention relates to an integrated method and system for the simultaneous production of biodiesel from free fatty acids (via esterification) and from triglycerides (via transesterification) within the same reaction chamber. More specifically, one preferred embodiment of the invention relates to a method and system for the production of biodiesel using an electrodeionization stack, wherein an ion exchange resin matrix acts as a heterogeneous catalyst for simultaneous esterification and transesterification reactions between a feedstock and a lower alcohol to produce biodiesel, wherein the feedstock contains significant levels of free fatty acid. In addition, because of the use of a heterogeneous catalyst, the glycerol and biodiesel have much lower salt concentrations than raw biodiesel produced by conventional transesterification processes. The present invention makes it much easier to purify glycerol and biodiesel.