The anus is the last part of the digestive tract. It is a 2-inch long canal consisting of the pelvic floor muscles and the two anal sphincters (internal and external). The lining of the upper anus is able to detect rectal contents. It lets you know whether the contents are liquid, gas or solid.
The anus is surrounded by sphincter muscles that are important in allowing control of stool. The pelvic floor muscle creates an angle between the rectum and the anus that stops stool from coming out when it’s not supposed to. The internal sphincter is always tight, except when stool enters the rectum. This keeps us continent (prevents us from pooping involuntarily) when we are asleep or otherwise unaware of the presence of stool.
When we get an urge to go to the bathroom, we rely on our external sphincter to hold the stool until reaching a toilet, where it then relaxes to release the contents.