Method of desalination and wastewater treatment in a microbial desalination cell reactor, characterized in that the microbial desalination cell reactor comprises three compartments, an anodic compartment, a cathodic compartment and a saline compartment, wherein an anionic exchange membrane is placed between the anodic compartment and the saline compartment and a cationic exchange membrane is placed between the cathodic compartment and the saline compartment, the method comprising: (a) adding electrically conductive particles or electrically conductive material that acts as support of an active biofilm of bacteria in the anodic compartment and acts as conductive material in the cathodic compartment; (b) adding bacteria species of the genus Geobacter cultured in a fresh water medium in the anodic compartment, adding an aqueous solution comprising an electrolyte as catholyte in the cathodic compartment, adding a saline solution in the saline compartment and desalinating said saline solution by applying an external power supply, and once the electroactive bacteria are introduced in the system, operating the desalination of a first saline solution in a microbial electrolysis configuration with external power supply; (c) when constant electric current is reached with a mature biofilm formed in the anode, replacing the aqueous solution comprising an electrolyte as catholyte by a first hypochlorite solution comprising soluble hypochlorite salts in the cathodic compartment, replacing the fresh water medium by wastewater in the anodic compartment, and removing power supply from the system and connecting an external load or an external circuit to anodic and cathodic electric collectors located in the anodic and cathodic compartments, respectively: (d) operating the cell as an autonomous microbial desalination cell without any external energy supply and oxidizing organic matter present in the wastewater fed in the anodic compartment by bacteria from the genus Geobacter in the anodic compartment, and desalinating the saline solution fed in the saline compartment and (e) after 20 to 30 operation cycles, removing biofouling on the membranes surface by introducing and circulating a second hypochlorite solution in the saline compartment. (a) adding electrically conductive particles or electrically conductive material that acts as support of an active biofilm of bacteria in the anodic compartment and acts as conductive material in the cathodic compartment; (b) adding bacteria species of the genus Geobacter cultured in a fresh water medium in the anodic compartment, adding an aqueous solution comprising an electrolyte as catholyte in the cathodic compartment, adding a saline solution in the saline compartment and desalinating said saline solution by applying an external power supply, and once the electroactive bacteria are introduced in the system, operating the desalination of a first saline solution in a microbial electrolysis configuration with external power supply; (c) when constant electric current is reached with a mature biofilm formed in the anode, replacing the aqueous solution comprising an electrolyte as catholyte by a first hypochlorite solution comprising soluble hypochlorite salts in the cathodic compartment, replacing the fresh water medium by wastewater in the anodic compartment, and removing power supply from the system and connecting an external load or an external circuit to anodic and cathodic electric collectors located in the anodic and cathodic compartments, respectively: (d) operating the cell as an autonomous microbial desalination cell without any external energy supply and oxidizing organic matter present in the wastewater fed in the anodic compartment by bacteria from the genus Geobacter in the anodic compartment, and desalinating the saline solution fed in the saline compartment and (e) after 20 to 30 operation cycles, removing biofouling on the membranes surface by introducing and circulating a second hypochlorite solution in the saline compartment.