In this study, bagasse was used as a carbon source to prepare magnetic porous biochar (MBC) through the method of high-temperature pyrolysis with K2FeO4 as the oxidation promoter. Different from the other two-step methods for preparing magnetic biochar, magnetic loading and graphitization can be realized in one step in this method at a high temperature with K2FeO4 as an activator. Through the characterization analyses of XRD, Raman, FT-IR, BET, VSM, and other methods, the modified MBC is proven to have a high degree of graphitization with a large specific surface area of 846.69 m2/g and a high saturation magnetization of 22.51 emu/g. As the adsorption process fitted with the Langmuir model, the maximum adsorption capacities of MBC-800 on the tetracycline (TC) and ciprofloxacin (CIP) were calculated to be 416.67 mg/g and 434.78 mg/g, respectively. The adsorption mechanism of MBC-800 for the adsorption of TC (or CIP) mainly includes π-π conjugation, pore filling, hydrogen bonding with oxygen-containing functional groups, and chemical adsorption including ion exchange and electrostatic attraction. MBC can maintain high adsorption capacity for TC (or CIP) after multiple cycles. The study is expected to provide a possibility for the preparation of magnetic biochar and extend our knowledge of its application in antibiotic wastewater treatment. © The Author(s), under exclusive licence to Springer-Verlag GmbH Germany, part of Springer Nature 2022. corrected publication 2023.