They had to do this by firing the lunar module rocket engine for just the right amount of time.
VOA: special.2009.07.22
After an explosion in Apollo 13's service module cut off propulsion and power, the lunar excursion module (LEM) was used as a lifeboat to provide life support to the three astronauts, and the engine of its descent stage for course changes, until the command module could re-enter the atmosphere after a long coast around the moon.