Emergency contraception is a method used to prevent pregnancy after unprotected sex or contraceptive failure. It is most effective when taken as soon as possible after the event. Medications like the morning-after pill (e.g., levonorgestrel or ulipristal acetate) work by delaying ovulation or preventing fertilization. These pills provide a safe and effective way to reduce the risk of unintended pregnancy when used promptly.