In this work, an electrochemical method for chemical oxygen demand (COD) and total nitrogen (TN, including ammonia, nitrate, and nitrite) removal from wastewater using a divided electrolysis cell was developed, and its process optimization was investigated. This process could effectively relieve the common issue of NO3−/NO2− over-reduction or NH4+ over-oxidation by combining cathodic NO3−/NO2− reduction with anodic COD/NH4+ oxidation. The activity and selectivity performances toward pollutant removal of the electrode materials were investigated by electrochemical measurements and constant potential electrolysis, suggesting that Ti electrode exhibited the best NO3−/NO2− reduction and N2 production efficiencies. In-situ Fourier transform infrared spectroscopy was used to study the in-situ electrochemical information of pollutants conversion on electrode surfaces and propose their reaction pathways. The effects of main operating parameters (i.e., initial pH value, Cl− concentration, and current density) on the removal efficiencies of COD and TN were studied. Under optimal conditions, COD and TN removal efficiencies from simulated wastewater reached 92.7% and 82.0%, respectively. Additionally, reaction kinetics were investigated to describe the COD and TN removal. Results indicated that COD removal followed pseudo-first-order model; meanwhile, TN removal followed zero-order kinetics with a presence of NH4+ and then followed pseudo-first-order kinetics when NH4+ was completely removed. For actual pharmaceutical wastewater treatment, 79.1% COD and 87.0% TN were removed after 120 min electrolysis; and no NH4+ or NO2− was detected.