Ambien is a brand name for the medication zolpidem, which is primarily prescribed to treat insomnia, a sleep disorder characterized by difficulty falling asleep or staying asleep. Zolpidem belongs to a class of medications called sedative-hypnotics, and it works by affecting certain chemicals in the brain to help initiate sleep.