This medication is used to help relieve sudden (breakthrough) cancer pain in people who are regularly taking moderate to large amounts of opioid pain medication. Fentanyl belongs to a class of drugs known as opioid analgesics. It works in the brain to change how your body feels and responds to pain.This medication should not be used to relieve mild or short-term pain (such as due to headache/migraine, dental procedures, surgery).