A reactor based on the generation of aerobic granules in a continuous flow configuration, for the biological treatment of biomass in the form of urban or industrial wastewater, the reactor comprising, in succession, from upstream to downstream: - an inlet for wastewater; - a first head tank operated in feast mode and under anaerobic conditions; - a second tank that performs the function of a biological selector for microorganisms which are favourable to the formation of dense structures such as granules, operated in feast mode, and subdivided into two compartments, a first compartment being configured so as to be operated successively and alternately under aerobic and anaerobic conditions and vice versa, so that the biomass is exposed in a dynamic way to alternating oxidizing and reducing conditions respectively, and so that it is possible to prolong or extend the anaerobiosis of the first head tank into said first compartment of the second tank, and to effect a corresponding prolongation of the storage of at least 70%, preferably at least 90%, of readily biodegradable COD (Chemical Oxygen Demand) in the form of polymers, and a second compartment configured so as to be operated continuously under aerobic conditions; - a third tank operated in famine mode, configured so as to be controlled under aerobic or anoxic conditions, the famine conditions being obtained by limiting the mass load to 0.35 kg COD kg -1 VSS day -1, preferably to 0.25 kg COD kg -1 VSS day -1; - a physical or gravity selector which is suitable for selecting particles with a high settling velocity of at least 2 m/h, preferably at least 3 m/h, and for carrying out a recirculation of these particles to the inlet of the reactor while also allowing for the transfer of other sludge to a clarification structure; - the aforementioned clarification structure, being provided with a first outlet for an effluent and a second outlet for the recirculation of sludges to the third tank of the reactor and the wasting of excess sludge; the first compartment of the second tank being provided with aeration means, means for measuring the content of dissolved oxygen and the quantity of injected air, based on the air flow rate or the operating speed of the aeration means, and regulation-control means that enable, by controlling aeration, switching from the aerobic mode to the anaerobic mode and vice versa in the first compartment of the second tank on the basis of a set point value for the oxygen demand, said oxygen demand being measured as the quantity of oxygen to be supplied so as to reach and maintain a determined content of dissolved oxygen as set point value, in mg O 2 g -1 VSS h -1, the anaerobic mode being selected or maintained for a value greater than this set point value. - an inlet for wastewater; - a first head tank operated in feast mode and under anaerobic conditions; - a second tank that performs the function of a biological selector for microorganisms which are favourable to the formation of dense structures such as granules, operated in feast mode, and subdivided into two compartments, a first compartment being configured so as to be operated successively and alternately under aerobic and anaerobic conditions and vice versa, so that the biomass is exposed in a dynamic way to alternating oxidizing and reducing conditions respectively, and so that it is possible to prolong or extend the anaerobiosis of the first head tank into said first compartment of the second tank, and to effect a corresponding prolongation of the storage of at least 70%, preferably at least 90%, of readily biodegradable COD (Chemical Oxygen Demand) in the form of polymers, and a second compartment configured so as to be operated continuously under aerobic conditions; - a third tank operated in famine mode, configured so as to be controlled under aerobic or anoxic conditions, the famine conditions being obtained by limiting the mass load to 0.35 kg COD kg -1 VSS day -1, preferably to 0.25 kg COD kg -1 VSS day -1; - a physical or gravity selector which is suitable for selecting particles with a high settling velocity of at least 2 m/h, preferably at least 3 m/h, and for carrying out a recirculation of these particles to the inlet of the reactor while also allowing for the transfer of other sludge to a clarification structure; - the aforementioned clarification structure, being provided with a first outlet for an effluent and a second outlet for the recirculation of sludges to the third tank of the reactor and the wasting of excess sludge;