For caffeine and its seven major metabolites (i.e., theobromine, theophylline, paraxanthine, 1-methylxanthine, 3-methylxanthine, 7-methylxanthine, and xanthine), an optimized analytical method using liquid chromatography-tandem mass spectrometry (LC-MS/MS) for their detection in wastewater samples was developed in this study. Extraction of these compounds (recoveries ranged from 60.3 to 83.2%) was made possible by combining universal polymeric reversedphase cartridge and polymeric strong cation exchange cartridge. This method was applied to the determination of caffeine and its metabolites in the influent and effluent of an anaerobic-anoxic-oxic (A2O) process. In the A2O influent, caffeine and its metabolites (except xanthine) ranged from 1.39 to 5.45 μg/L, and their concentrations in the A2O effluent ranged from 10.2 to 171.3 ng/L. The mass load of caffeine was 14.9 g/day/1000 inhabitants, considering the population served by the target wastewater treatment plant (WWTP). The concentration of caffeine derivatives in wastewater influent is a tool for estimating the population size in the area served by WWTPs.