Ambien and Lunesta are both powerful prescription medications used to treat persistent insomnia. Both are in a class of drugs called nonbenzodiazepine hypnotics, which act on GABA receptors in the brain to induce a calming effect that is helpful for initiating sleep.