Trabeculectomy is a surgical procedure used to treat glaucoma by creating a drainage fistula to lower intraocular pressure. It is typically considered when medication and laser treatments have failed to adequately control the condition, aiming to prevent further optic nerve damage and vision loss.