JOHANNESBURG — Nelson Mandela, South Africa’s first black president and an enduring icon of the struggle against racial oppression, died on Thursday, the government announced, leaving the nation without its moral center at a time of growing dissatisfaction with the country’s leaders.

“Our nation has lost its greatest son,” President Jacob Zuma said in a televised address late Thursday night, adding that Mr. Mandela had died at 8:50 p.m. local time. “His tireless struggle for freedom earned him the respect of the world. His humility, his compassion and his humanity earned him their love.”

Mr. Zuma called Mr. Mandela’s death “the moment of our deepest sorrow,” and said that South Africa’s thoughts were now with the former president’s family. “They have sacrificed much and endured much so that our people could be free,” he said.

Mr. Mandela spent 27 years in prison after being convicted of treason by the white minority government, only to forge a peaceful end to white rule by negotiating with his captors after his release in 1990. He led the African National Congress, long a banned liberation movement, to a resounding electoral victory in 1994, the first fully democratic election in the country’s history.