Doctors said the 94-year-old human rights icon is responding well to treatment. Mandela has been hospitalized in South Africa since Saturday. He suffered from a similar illness last year.
The tests Mandela underwent at the hospital detected the lung infection, said presidential spokesman Mac Maharaj in a statement.
In recent days, many people have been complaining about the lack of concrete details released about Mandela's condition.
Mandela was imprisoned for nearly three decades for his fight against apartheid before becoming the nation's president in the country's first fully democratic vote in 1994.
The Associated Press contributed to this report.