A device for sterilizing containers includes a first treatment space, which is filled with a sterilizing gaseous medium under predetermined thermodynamic conditions, a tank, which is filled with a liquid medium and extends along a closed path, and a multiplicity of holding devices for holding the containers. The holding devices are arranged rotatably with respect to the treatment space, and a dividing wall, which protrudes into the liquid medium located in the tank is arranged rotatably with respect to the tank. A discharge opening, via which the gaseous medium can be discharged, is provided between the treatment space and the tank.