New York University’s president Andrew Hamilton had been on the job for four months when he faced his first student uprising.

For about 33 hours, undergraduates calling for the school to divest its holdings in fossil-fuel companies crammed into an elevator that leads to his office. They eventually struck a deal with administrators and later met with Mr. Hamilton himself.

“Nothing...