NAIROBI, Kenya (AP) — A court has sentenced two tuberculosis patients who skipped their medications to spend eight months in prison to avoid spreading the deadly disease among the public, a senior health official said Saturday.

The male patients were locked up in Kapsabet prison in western Kenya nearly 10 days ago to make sure they take their pills as prescribed and do not infect others, said Joseph Sitienei, the head of tuberculosis and lung diseases at the public health and sanitation ministry.

A person whose immune system is compromised by HIV is particularly susceptible to tuberculosis, which is caused by bacteria that usually attack the lungs. The disease is spread through the air when an infected person coughs or sneezes.

Sitienei said the judge who sentenced the pair invoked a rarely utilized law that allows the government to jail patients with infectious diseases to safeguard the public health.

"If you look at the risk these people pose to those who have problems with their immune systems ... then you can see this is a bush fire that actually needs to (be) put off immediately," Sitienei said.

If tuberculosis treatment is stopped short, the bacteria fight back and mutate into a tougher strain, requiring longer treatment and more expensive drugs. Over the last three years, the number of Kenyans infected with multi-drug resistant TB has increased from 82 in 2007 to 150 in 2010.

Kenya is ranked among the 22 countries hardest hit by tuberculosis, with an estimated 200 people dying each day from the disease despite the government's free diagnosis and treatment of TB patients.