JOHANNESBURG — President Jacob G. Zuma agreed on Friday to freeze tuition fees at South Africa’s public universities, yielding to widening protests by students who streamed into the capital, Pretoria, by the thousands and protested outside his office.

In a short televised statement, Mr. Zuma said he had made the decision after meeting with student leaders and top university administrators, but did not elaborate on his thinking. “Government understands the difficulty faced by students from poor households and urges all affected to allow the process to unfold to find long-term solutions in order to ensure access to education by all students,” he said.

In the largest protest organized by university students this year, thousands from campuses across the country rallied Friday at the Union Buildings, the seat of power in South Africa, chanting and holding signs demanding a freeze on tuition and criticizing Mr. Zuma’s administration.

Most students protested peacefully. But some started fires and tore parts of a fence around the Union Buildings, hurling rocks at riot police officers and demanding that Mr. Zuma address them directly. The police responded by firing stun grenades and using a water cannon to disperse the crowds, and unfurled barbed wire to prevent protesters from moving inside.