This is the first report on development of a library search-based screening system for 3,4-methylenedioxymethamphetamine (MDMA) in ecstasy tablets using a portable near-infrared (NIR) spectrometer. The spectrum library consisted of spectra originating from standard substances as well as mixtures of MDMA hydrochloride (MDMA-HCl) and diluents. The raw NIR spectra were mathematically pretreated, and then, a library search was performed using correlation coefficient. To enhance the discrimination ability, the wavelength used for the library search was limited. Mixtures of MDMA-HCl and diluents were used to decide criteria to judge MDMA-positive or MDMA-negative. Confiscated MDMA tablets and medicinal tablets were used for performance check of the criteria. Twenty-two of 27 MDMA tablets were truly judged as MDMA-positive. Five false-negative results may be caused by compounds not included in the library. No false-positive results were obtained for medicinal tablets. This system will be a useful tool for on-site screening of MDMA tablets.