John S. Toll, a physicist and educator who was president of Stony Brook University on Long Island during the public university building boom of the Rockefeller years, overseeing its transition from a state college with 1,700 students to a major research institution with an enrollment of 17,000, died on Friday in Bethesda, Md. He was 87.

The cause was respiratory failure, his family said.

After leaving Stony Brook in 1978, Dr. Toll, who had taught physics and astronomy for a dozen years at the University of Maryland, returned there and oversaw an expansion comparable in scope to the one he had managed on Long Island, expanding the University of Maryland system to 11 campuses from 5 and improving its national ranking.

Dr. Toll, who received his Ph.D. from Princeton in the early 1950s, was appointed the first president of Stony Brook University in 1965 at the age of 41.

Gov. Nelson A. Rockefeller, who took a hand in his hiring, saw in Dr. Toll’s academic credentials and hard-driving style the sort of leadership he wanted for meeting his expectations for Stony Brook. “He wanted Johnny Toll to make Stony Brook the Berkeley of the East,” said John H. Marburger III, a fellow physicist who succeeded Dr. Toll as president of Stony Brook and who later became the science adviser to President George W. Bush.