Endometriosis. There are certain proinflammatory substances that are secreted by the ectopic endometrial tissue that are very irritating to adjacent tissues and nerve endings causing pain. These substances, ie prostaglandin, will cause uterine contractions that are also painful.
Inflamation. Endometriosis causes internal swelling and inflammation which causes scaring. This then leads to pain.