Heparin is an anticoagulant medication that is used to prevent and treat blood clots. It works by inhibiting the formation of clots and is often administered to patients undergoing surgery or those with certain medical conditions that predispose them to clot formation.