The ability of a substance to kill or inhibit the growth of microorganisms, such as bacteria or viruses.