It works on conservation of momentum because initially the system is at rest and then the rocket starts releasing gas which causes the change in momentum and hence to make the net change in momentum zero because no force is acting the rocket moves in opposite direction that is upward.