The Moon goes around Earth in $27.3$ days relative to the stars, yet new moon to new moon takes $29.5$ days. If that sounds familiar, it should: it is the same puzzle as the solar and sidereal days, on a bigger scale. And since phases depend on the Sun, as in moon phases and moonrise times, the phase cycle uses the Sun as its reference.
Sidereal month: one orbit relative to the stars, $27.32$ days.
Synodic month: one cycle of phases, new moon to new moon, $29.53$ days.
💡 Why it works
In $27.3$ days Earth carries the Earth–Moon pair about $27^\circ$ along its orbit, so the Sun appears about $27^\circ$ farther east among the stars. When the Moon is back at the same stars, it still has to catch up those $27^\circ$ to be lined up with the Sun again, which takes about two more days. In rates: the Moon moves $360^\circ / 27.32 = 13.18^\circ$ per day against the stars, the Sun $360^\circ / 365.25 = 0.99^\circ$ per day, so the Moon gains $12.19^\circ$ per day on the Sun and needs $360^\circ / 12.19^\circ = 29.53$ days to lap it. As a formula: $\dfrac{1}{S} = \dfrac{1}{P} - \dfrac{1}{Y}$.
🔑 Key idea
Synodic month $S$ (phases): $\dfrac{1}{S} = \dfrac{1}{P_{\text{sidereal}}} - \dfrac{1}{P_{\text{year}}}$, giving $29.53$ days, longer than the $27.32$-day orbit because Earth moves along its orbit too.
The Moon's orbit with sunlight from the left. At 27.3 days the Moon has gone once around relative to the stars but is still a thin crescent.
Worked examples
✏️ Worked example: The Moon's numbers
Use $P = 27.32$ days and $Y = 365.25$ days to find the synodic month.
$\frac{1}{27.32} = 0.036603$ and $\frac{1}{365.25} = 0.002738$ per day.
$\frac{1}{S} = 0.036603 - 0.002738 = 0.033865$ per day.
$S = 1 \div 0.033865 = 29.53$ days.
Answer: $29.53$ days.
✏️ Worked example: A planet's cycle
Mars orbits the Sun in $1.88$ years. How often does Earth pass Mars (from one opposition to the next)?
Earth laps Mars, so use the faster minus the slower rate: $\frac{1}{S} = \frac{1}{1} - \frac{1}{1.88} = 1 - 0.532 = 0.468$ per year.
$S = 1 \div 0.468 = 2.14$ years.
That is how often Mars is closest and brightest, and how often it loops backward in our sky.
Answer: About every $2.14$ years (about 780 days).
Time it yourself in the Sky and Solar System lab: run the Moon through a few months and count the days from one new moon to the next.
⚠️ Common mistake
It is easy to think the phases repeat once per orbit. They repeat once per lap of the Sun, which takes longer. Check with the numbers: after $27.3$ days the Moon is back among the same stars, but it is a crescent, not new. The extra $2.2$ days is the time to catch up with the Sun's $27^\circ$ move.