SANGZAO, China  The students lined up row by row on the outdoor basketball courts of Sangzao Middle School in the minutes after the earthquake. When the head count was complete, their fate was clear: all 2,323 were alive.

Parents covered in blood and dust hugged them and cried. So did the school principal, Ye Zhiping.

“That was the single most joyful thing,” he said.

Given that some 10,000 other children were crushed in their classrooms during the devastating quake on May 12, the survival of so many students in Sangzao counts as a minor miracle.

Students and parents credit that to the man they call Angel Ye.

Nervous about the shoddiness of the main school building, Mr. Ye scraped together $58,000 to renovate it in the 1990s. He had workers widen concrete pillars and insert iron rods into them. He demanded stronger balcony railings. He demolished a bathroom whose pipes had been weakened by water.