Heparin is an anticoagulant medication used to prevent and treat blood clots in conditions such as deep vein thrombosis, pulmonary embolism, and during surgeries. It works by enhancing the activity of antithrombin III, which inhibits thrombin and factor Xa, crucial components in the blood coagulation cascade.