The excretory system of insects involves several organs that work together to remove nitrogenous waste from the body. The main excretory organs are the Malpighian tubules, which produce a filtrate that selectively reabsorbs water and ions while eliminating waste. For terrestrial insects, the main waste product is uric acid, while aquatic insects excrete ammonia. The filtrate produced by the Malpighian tubules passes to the gut where further modification occurs before excretion, helping to maintain fluid and ion balance in the insect's body.