Donald F. Hornig, who as a young scientist once “babysat” the world’s first atomic bomb and who later became Brown University president and the top science adviser to President Lyndon B. Johnson, died Jan. 21 at a nursing home in Providence, R.I. He was 92.

He had Alzheimer’s disease, his son, Christopher Hornig, said.

Only a year out of graduate school, Dr. Hornig was recruited in 1944 for the top-secret Manhattan Project in Los Alamos, N.M.

The World War II project, directed by J. Robert Oppenheimer, was designed to produce an atomic bomb. Dr. Hornig led a team that developed a device called the “X unit,” the firing mechanism for the bomb.

The first nuclear bomb — called “the gadget” by scientists — was scheduled to be detonated near Alamogordo, N.M., on Monday, July 16, 1945.

President Johnson's science adviser Donald L. Hornig (left) during a trip to Europe in February 1966. (Photo by UPI)

“On the Sunday before the test, shortly before 9 p.m.,” Dr. Hornig recalled in a 1995 article in the Christian Science Monitor, “Oppenheimer decided someone should be in the tower to baby-sit the bomb because of the possibility of sabotage. Maybe because I was the youngest, I got the job. In the darkness, amid heavy rain, lightning, and strong winds, I climbed the ladder to the top of the 100-foot tower.”

To take his mind off the bomb beside him, Dr. Hornig attempted to read a paperback novel under a 60-watt bulb.

“I stopped frequently to count the seconds between the sound of a thunder clap and the lightning flash,” he told the Monitor, “and tried not to think of what might happen if the tower got a direct hit and the gadget went off. At least I would never know about it.”

Early the next morning, Dr. Hornig climbed down from the tower and took his place beside Oppenheimer in a control room more than five miles away.

“My right hand was poised over a control switch that would stop the test if something went wrong,” he said in the interview. The bomb exploded at 5:29:45 a.m.

“My first reaction, having not slept for 48 hours, was ‘Boy, am I tired,’ ” Dr. Hornig recalled. “My second was, ‘We sure opened a can of worms.’ Nobody knew where this would lead, but I had no regrets.”

Donald Frederick Hornig was born March 17, 1920, in Milwaukee. He was a 1940 graduate of Harvard University, where he also received a doctorate in physical chemistry in 1943.

After working at the Woods Hole Oceanographic Institution in Massachusetts, he joined the Manhattan Project because of his expertise on shock waves produced by large explosions.

Dr. Hornig joined the faculty at Brown University in 1946, then moved to Princeton University in 1957. He served on science advisory panels of four presidents, beginning with Dwight D. Eisenhower.

In November 1963, Dr. Hornig was tapped as the top White House science adviser by President John F. Kennedy, who was assassinated two weeks later. Dr. Hornig became head of the White House Office of Science and Technology in January 1964, after Johnson had assumed the presidency.

Business Week reported that the job “is expected to be one of the hottest seats in the Johnson administration,” but Dr. Hornig often found himself having to defend federal research programs from budget cutters in Congress.

At the other end of Pennsylvania Avenue, he said he sometimes had a hard time getting Johnson’s attention. He left at the end of Johnson’s term, in January 1969.

“I was never on easy personal terms with the president,” Dr. Hornig told Science magazine at the time. “There’s always been a certain gap in attitude and approach between a Texas rancher and an Ivy League professor. I was on much easier terms with Kennedy, who asked me to serve in the first place.”

Dr. Hornig was named president of Brown in 1970. He merged an affiliated women’s college, Pembroke, with the all-male Brown and helped establish a medical school at the university.

He also wrestled with a $4 million deficit and a confrontational student body that went on strike in 1975 to protest cuts in popular classes and programs. Dr. Hornig ordered a 15 percent cut in spending that included the dismissal of many faculty members. By the time he resigned in 1976, he was unpopular with students and professors, but he was eventually credited with steering the Ivy League university toward financial stability.

Dr. Hornig finished his career at the Harvard School of Public Health, where he established an interdisciplinary program in public health. He retired in 1990.

Survivors include his wife of 69 years, Lilli Schwenk Hornig of Providence; three children, Joanna Fox and Christopher Hornig, both of Washington, and Ellen Hornig of Shrewsbury, Mass.; a brother; a sister; nine grandchildren; and 10 great-grandchildren.

A daughter, Leslie Hornig, died in 2012.

In a 1964 article examining the state of science in the Johnson administration, a writer for Time magazine questioned whether Dr. Hornig could accomplish much because he “is a virtual stranger on the Washington scene.”

In a letter to the editor, Dr. Hornig’s 10-year-old son took exception. “My father has served for three Presidents,” Christopher Hornig noted, “and is in Washington so much that by now he is a virtual stranger to me.”