When you discard a card with madness, it is exiled instead of going to the graveyard. This triggers the madness ability, which gives you the opportunity to cast the card from exile for its madness cost. Crucially, this all happens before opponents receive priority. (CR 702.35)
Specifically, the madness triggered ability goes on the stack and, when it resolves, you may cast the spell immediately at that point. Your opponents do not get a chance to respond between the discard event and the resolution of the madness trigger in a way that would prevent you from casting it — though they can respond once the spell itself is on the stack. (CR 702.35b, 702.35c)
If you choose NOT to cast the card for its madness cost when the ability resolves, the card is simply put into your graveyard instead. You cannot hold the card in exile and cast it later. (CR 702.35c)
Concrete example: Your opponent casts Thoughtseize and you discard Fiery Temper (which has madness {R}). Fiery Temper is exiled, its madness trigger goes on the stack, and when it resolves you may cast Fiery Temper for just {R}. Your opponent does not get another action before you decide — they can only respond once Fiery Temper is actually on the stack.
So madness is designed to protect your spell: opponents cannot use priority between the discard and your cast opportunity to, for example, remove a required resource before you can use it.
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.