Heparin is a glycosaminoglycan composed of repeating units of uronic acid and glucosamine. It functions primarily by binding to the enzyme inhibitor antithrombin III (AT), which in turn inhibits thrombin and other proteases involved in blood clotting. This mechanism is crucial for preventing coagulation in blood samples and tissue preparations.