The rectum stores feces prior to its release through the anus, according to Healthline. This source also states that the rectum is the final segment of the large intestine.
Encyclopedia Brittanica explains that the walls of the rectum distend as fecal material enters and accumulates; once enough pressure is built up, the urge to eliminate occurs. The nervous system activates the muscles of the anal canal, chest and abdominal wall so that elimination can occur; it sends an impulse to the brain to make a person aware of the need to eliminate, according to Encyclopedia Brittanica.
Healthline notes that constipation can result if a person delays defecation once the rectum reaches sufficient pressure for elimination.