Diseases caused by pathogenic bacteria in animals (e.g., bacterial pneumonia, meningitis and sepsis) and plants (e.g., bacterial wilt, angular spot and canker) lead to high prevalence and mortality, and decomposition of plant leaves, respectively. Melatonin, an endogenous molecule, is highly pleiotropic, and accumulating evidence supports the notion that melatonin’s actions in bacterial infection deserve particular attention. Here, we summarize the antibacterial effects of melatonin in vitro, in animals as well as plants, and discuss the potential mechanisms. Melatonin exerts antibacterial activities not only on classic gram-negative and -positive bacteria, but also on members of other bacterial groups, such as Mycobacterium tuberculosis. Protective actions against bacterial infections can occur at different levels. Direct actions of melatonin may occur only at very high concentrations, which is at the borderline of practical applicability. However, various indirect functions comprise activation of hosts’ defense mechanisms or, in sepsis, attenuation of bacterially induced inflammation. In plants, its antibacterial functions involve the mitogen-activated protein kinase (MAPK) pathway; in animals, protection by melatonin against bacterially induced damage is associated with inhibition or activation of various signaling pathways, including key regulators such as NF-κB, STAT-1, Nrf2, NLRP3 inflammasome, MAPK and TLR-2/4. Moreover, melatonin can reduce formation of reactive oxygen and nitrogen species (ROS, RNS), promote detoxification and protect mitochondrial damage. Altogether, we propose that melatonin could be an effective approach against various pathogenic bacterial infections.