To explore the mechanism of mitochondrial uncoupling protein 2 (UCP2) mediating the protective of melatonin when septic cardiomyopathy. UCP2 knocked out mice and cardiomyocytes were used to study the effect of melatonin in response to LPS. Indicators of myocardial and mitochondria injury including mitochondrial membrane potential, mitochondrial permeability transition pore, calcium loading, ROS, and ATP detection were assessed. In addition cell viability and apoptosis as well as autophagy-associated proteins were evaluated. Melatonin was able to protect heart function from LPS, which weakened in the UCP2-knockout mice. Consistently, genipin, a pharmacologic inhibitor of UCP2, augmented LPS-induced damage of AC16 cells. In contrast, melatonin upregulated UCP2 expression and protected the cells from the changes in morphology, mitochondrial membrane potential loss, mitochondrial Ca2+ overload, the opening of mitochondrial permeability transition pore, and subsequent increased ROS generation as well as ATP reduction. Mitophagy proteins (Beclin-1 and LC-3β) were increased while apoptosis-associated proteins (cytochrome C and caspase-3) were decreased when UCP2 was up-regulated. In conclusion, UCP2 may play a protecting role against LPS by regulating the balance between autophagy and apoptosis of cardiomyocytes, and by which mechanisms, it may contribute to homeostasis of cardiac function and cardiomyocytes activity. Melatonin may protect cardiomyocytes through modulating UCP2.