Answer
The engine can expel hot exhaust, compressed gas, or ions in a given direction. The gas-rocket system is isolated and its momentum stays constant.
Work Step by Step
If some mass is expelled, say, to the left, then the rocket and the remaining gas moves to the right to keep the overall momentum the same (this situation can also be analyzed using Newton’s third law).