The first person to synthesized MDMA was German chemist Anton Köllisch. While working for the German pharmaceutical company Merck, Köllisch created MDMA as a by-product while trying to synthesize another substance (hydrastinine). During the same year, Merck filed to patent the method of preparation used by Köllisch.
Source: Benzenhöfer, U., & Passie, T. (2006). [The early history of" Ecstasy"]. Der Nervenarzt.