The purpose of the malpighian tubule is to absorb and excrete the metabolic wastes that make up urine in arthropods. They actively absorb water, dissolved substances and waste from the surrounding body fluids to be released as solid nitrogen-based compounds.
The malpighian tubules absorb urea and amino acids very easily, but ions such as potassium and sodium are actively pumped in through their membranes. The tubules carry these wastes to the rectum, where water and ions are reabsorbed and the urea is mixed with feces to be excreted through the anus. Various species have specialized purposes for the malpighian tubules beyond these basic functions. New Zealand glow worms have modified tubules that generate light to attract prey to their sticky trap lines, which they dangle from cave ceilings. Other insects that eat toxic plants have special mechanisms to quickly excrete any toxins through the tubules.
Malpighian tubules are slender tubes with walls composed of a single layer of cells. Most are highly convoluted and bathed in hemolymph, the arthropod equivalent of blood and lymph fluid, for much of their length. They are reinforced with proteins and have structures to help push any wastes along. Most arthropods have muscles that move the tubules around, although some species lack these muscles and others lack tubules altogether.