The rectal gland is a specialized organ found in some elasmobranch fishes, such as sharks and rays, that plays a critical role in osmoregulation by excreting excess salts. This adaptation allows these fish to thrive in marine environments where the surrounding water is saltier than their bodily fluids. The gland functions by filtering out ions and facilitating their excretion, thus helping maintain the internal balance of salts and water.