Ambien is a prescription medication that is used to treat insomnia. It comes in two forms: immediate release and extended-release. Immediate release Ambien works quickly, helping you fall asleep within 30 minutes of taking it. Extended-release Ambien can take up to an hour to work, but it generally lasts throughout the night so you won’t have trouble sleeping again during the same night that you take it.