Water pollution by Gasoil seriously threatens the environment and human health. Removing Gasoil from the aqueous solutions is critical to maintaining the safety and quality of the water source. This research looked at the feasibility of filtering Gasoil out of water. As a first step, we developed a new adsorbent from Prosopis farcta cellulose fibers by preparing a metal-organic magnetic framework (cellulose@Fe3O4@ZIF-8 carbon aerogel magnetic). The design of experiment method was utilized to explore how variations in pH, Gasoil concentration, and adsorbent dose influenced the elimination of Gasoil. Adsorbent has an adsorption capacity of 7 g.g− 1 and can adsorb 100% of the petroleum floating in water. Time studies demonstrated no time dependence in the Gasoil adsorption process by the adsorbent. Freundlich isotherm described the adsorption of petroleum onto the prepared magnetic carbon aerogel. The free energy, enthalpy, and entropy changes as a part of the Gibbs thermodynamic equation were determined. The proposed magnetic carbon aerogel was an effective adsorbent for extracting petroleum from the aqueous solutions because of its rapid separation and high stability. Even after eight times of use, this adsorbent maintained its relatively high adsorption capacity, and only a 10% drop in adsorption efficiency was observed.