Device for treating wastewater comprising at least one tank having an entirely aerobic microbiological bed reactor with gravitational water percolation with: a wastewater inlet in the upper part of the aerobic reactor and a purified water drain in the lower part of the tank, and a pretreatment compartment upstream of the aerobic reactor suitable for settling and/or anaerobic digestion of the wastewater, an outlet from the pretreatment compartment being connected to the water inlet of the aerobic reactor and comprising a primary filter arranged to limit the transfer of solid or supernatant materials to the aerobic reactor, the microbiological bed comprising at least two superposed layers of microbiological supports in the form of hard granules of a particle size between 5 and 30 mm, two adjacent superposed layers being separated from one another by one or more intermediate oxygenation zones without granules, the intermediate oxygenation zone or zones being connected, on the one hand, to an air intake and, on the other hand, to an outlet by natural upward ventilation, a vertical tube placed in the aerobic reactor, the lower end of which is located below the level of the purified water drain and the upper end of which is the air intake located above the upper level of the tank open to the free atmosphere; the vertical tube having an opening at the height of the intermediate oxygenation zone or zones and being connected to the air intake, oxygen transfer taking place via one or more air circulation windows provided in the tube of the air intake at the height of the intermediate oxygenation zone, oxygenation being carried out, on the one hand, by passage of the water in droplet form, preferably in the form of rain, through the intermediate oxygenation zone or zones and, on the other hand, by passage of air through the interstices formed between the hard granules countercurrently to percolation of water from the top downwards. an entirely aerobic microbiological bed reactor with gravitational water percolation with: a wastewater inlet in the upper part of the aerobic reactor and a purified water drain in the lower part of the tank, and a wastewater inlet in the upper part of the aerobic reactor and a purified water drain in the lower part of the tank, and a pretreatment compartment upstream of the aerobic reactor suitable for settling and/or anaerobic digestion of the wastewater, an outlet from the pretreatment compartment being connected to the water inlet of the aerobic reactor and comprising a primary filter arranged to limit the transfer of solid or supernatant materials to the aerobic reactor, the microbiological bed comprising at least two superposed layers of microbiological supports in the form of hard granules of a particle size between 5 and 30 mm, two adjacent superposed layers being separated from one another by one or more intermediate oxygenation zones without granules, the intermediate oxygenation zone or zones being connected, on the one hand, to an air intake and, on the other hand, to an outlet by natural upward ventilation, two adjacent superposed layers being separated from one another by one or more intermediate oxygenation zones without granules, the intermediate oxygenation zone or zones being connected, on the one hand, to an air intake and, on the other hand, to an outlet by natural upward ventilation, on the one hand, to an air intake and, on the other hand, to an outlet by natural upward ventilation, a vertical tube placed in the aerobic reactor, the lower end of which is located below the level of the purified water drain and the upper end of which is the air intake located above the upper level of the tank open to the free atmosphere; the vertical tube having an opening at the height of the intermediate oxygenation zone or zones and being connected to the air intake, oxygen transfer taking place via one or more air circulation windows provided in the tube of the air intake at the height of the intermediate oxygenation zone, oxygenation being carried out, on the one hand, by passage of the water in droplet form, preferably in the form of rain, through the intermediate oxygenation zone or zones and, on the other hand, by passage of air through the interstices formed between the hard granules countercurrently to percolation of water from the top downwards.