JOHANNESBURG, South Africa -- Nelson Mandela, South Africa's beloved first black president and anti-apartheid hero, has died after suffering recurring lung infections that were the legacy of tuberculosis contracted in prison during his long fight against oppression, President Jacob Zuma said in a televised address late Thursday. He was 95.

Although out of the limelight in recent years because of the infirmities of age, Mandela, or Madiba, the clan name by which he was affectionately known to many South Africans, remained a revered symbol of the fight he led against the nation's apartheid regime.

Mandela was admitted to a Pretoria hospital in June for the fifth time in two years. Although he was sent home three months later, family members said he had been living in a sterilized bedroom rigged as an intensive care unit with doctors tending to him around the clock.

Even on what his daughter, Makaziwe, termed his "deathbed," Mandela remained an inspiration.

"He is teaching us lessons; lessons in patience, in love, lessons of tolerance," she told the state-owned television network SABC this week.

Mandela was born July 18, 1918, the son of a tribal chief. He was named Rolihlahla, or "troublemaker" in his Xhosa language. A teacher gave him the name Nelson on his first day of school, but South Africans called him Madiba throughout his life in a sign of affection and respect for his clan.

Mandela had a history of respiratory illness after contracting tuberculosis in 1988 during his 27-year imprisonment for his activities as a member of the then-banned African National Congress liberation movement.

After his 1990 release, he reached out to a frightened white minorityand helped guide tense constitutional talks and political reforms. He became president after the 1994 election, succeeding the man who orchestrated his release, President Frederik W. de Klerk, a year after the two men shared the Nobel Peace Prize for shepherding South Africa out of four decades of racial segregation and repression.

Under Mandela's rule, the economy grew, a constitution guaranteeing equality and press freedom took root, and a Truth and Reconciliation Commission shed light on the dark deeds of apartheid. It granted amnesty to both whites and blacks accused of political violence.

During his five years as president, Mandela’s courtly demeanor and commitment to consensus governance set him apart on a continent trying to move away from an era of dictatorship and corruption. His decision in 1999 not to seek another presidential term was a move almost unheard of among African leaders. The ANC held on to the presidency in subsequent elections.

Mandela remained on the world stage as an activist in the fight against AIDS, having lost a son to the disease in 2005. He also traveled widely in support of human rights and efforts to fight poverty. He spoke out forcefully against the U.S.-led invasion of Iraq in 2003, accusing President George W. Bush of trying to "plunge the world into a holocaust."

Mandela formally retired from politics almost a decade ago and lived most of the time since in his ancestral village of Qunu in Eastern Cape province, until illness forced him to take up residence closer to medical facilities near Johannesburg.

His last major public appearance was in 2010, when South Africa hosted the World Cup soccer championship.