If the emergency contraceptive pill is taken during the first half of the menstrual cycle, it works specifically to prevent ovulation – even if the egg is mature and ready to be released, it will not be, meaning the sperm cannot fertilise it.
If it's too late to prevent ovulation and the mature egg has already been released, the emergency contraceptive pill is believed to thicken cervical mucus and trap sperm. It may also directly inhibit fertilization between sperm and egg.
The IUD works by releasing copper to stop the egg implanting in the womb or being fertilised.