3 answers
The leak fix is the real priority - that part's nonnegotiable. Once you've stopped the water coming in, let the ceiling dry out completely before you touch it with compound or paint, because moisture trapped behind a fresh patch will just bubble and peel. If the stain is massive and the drywall's soft or sagging, you might need to cut out that section and replace it rather than just sanding and filling; smaller stains you can get away with primer and compound, but don't skip the primer or the stain will bleed through again.
Find and fix the leak first, or you're just patching a problem that'll come right back. Water stains mean moisture is still getting in from above - could be a roof leak, plumbing issue, or condensation problem. Identify the source and seal it before you touch the ceiling, otherwise the stain will bleed through any paint or patch you apply.
Once the leak is handled, the repair depends on how deep the damage goes. For surface stains on intact drywall, sand the stained area lightly, prime it with a stain-blocking primer (this matters - regular primer won't stop water stains from bleeding through), then paint over it. If the drywall is soft, spongy, or crumbly, that section is compromised and needs to be cut out and replaced with new drywall board.
For large stains, you might need to replace a whole panel or section rather than trying to blend a patch. Cut out a rectangle around the damaged area, use drywall scraps to back the edges if needed, fit new drywall in, tape and mud the seams, sand smooth, prime with that stain blocker again, and paint. It takes longer than a quick cosmetic fix, but it actually holds up. And seriously - confirm that leak is truly gone before closing anything up, or you'll be doing this again in six months.
The moisture has gotta be completely gone before you touch anything - paint or primer over damp drywall and you'll trap that water inside, making the stain come back worse and the whole ceiling could start sagging or growing mold! let it dry out fully (could take weeks depending on how bad it is) use a moisture meter to check if you're actually ready, then prime with a stain-blocking sealer before your final paint coat.
Your answer
Log into answer.