Gabapentin is used to treat epilepsy. It's also taken for nerve pain, which can be caused by different conditions, including diabetes and shingles. Nerve pain can also happen after an injury. In epilepsy, it's thought that gabapentin stops seizures by reducing the abnormal electrical activity in the brain.