Rocket works on the principle of conservation of momentum.
Law of conservation of linear momentum states that in an isolated system the total momentum remains conserved.
The momentum of the rocket should still remain zero after firing (i.e., when the rocket is moving in a gravity-free space) since the initial momentum of the rocket and fuel is zero.
Since the momentum of the exhaust is vertically downwards, the momentum of the rocket should be vertically upwards so that the total momentum remains zero. The momentum gained by the rocket propels it.
An action-reaction pair is also formed as the rocket engines are ignited, the rocket acts on the exhaust gases and thus, in turn, the exhaust gases react on the rocket.