Pharmaceuticals constitute one of the most important emerging classes of environmental pollutants. A three‐phase solvent system of water, water containing 0.1% of formic acid and acetonitrile was successfully used to separate, by liquid chromatography with mass spectrometry (LC‐MS), polarity‐matched pharmaceuticals, that is, carbamazepine, clarithromycin, and erythromycin, as well as amoxicillin and metformin. Despite of polarity similarities, these pharmaceuticals were completely resolved in the analytical run time of 15 min. The optimized three‐phase solvent system based‐method was validated for the simultaneous analysis of six matched‐polarity pharmaceuticals in wastewater samples. Good linearity (coefficient of determination more than 0.993) and precision (relative standard deviation less than 15.66%) were achieved. Recovery of analytes from the wastewater was between 0.70 and 1.18. Limits of detections ranged from 0.0001 to 0.5114 µg/L. No significant matrix effect, evaluated by post extraction addition, was observed in the electrospray ionization (ESI) source. Then, this methodology has been successfully applied to environmental study of pharmaceutical residues occurring in influent and effluent wastewater samples, from the main wastewater treatment plant in Potenza (Basilicata, Southern Italy).