The rectum constitutes the final section of the large intestine (colon) that connects to the anus. This segment, approximately 12-15 cm in length, begins at the terminal end of the colon and concludes with a narrow passage leading to the anus. The primary function of the rectum is to temporarily store feces prior to their expulsion from the body.

The rectal wall is composed of three main layers:
1. Mucosa: This inner layer contains glands that secrete mucus to facilitate the passage of stool.
2. Muscularis Propria: Forming the middle layer, this section houses muscle fibers responsible for contractions that aid in the propulsion of feces.
3. Outer Layer (Serosa/Adventitia): The outermost layer of the rectum is covered by peritoneum (serosa) in its upper parts and by adventitia, consisting of connective tissue, in its lower parts.

In addition to these layers, lymph nodes, which are part of the immune system, are also found around the rectum.