This medication is used to treat a certain sleep problem (insomnia). It may help you fall asleep faster, stay asleep longer, and lessen how often you wake up during the night, so you can get a better night's rest. Temazepam belongs to a class of drugs called benzodiazepines.