Margaret Hamilton, the computer scientist whose software helped guide Nasa's astronauts to the surface of the Moon, has died aged 90.

Her former employer, the Massachusetts Institute of Technology (MIT), confirmed she died on 30 September.

"To say Hamilton was a pioneer — to say she was ahead of her time — would be a dramatic understatement," MIT said, noting that she was a software engineer before the profession was recognised.

The first programmer on Apollo

Hamilton worked at MIT from 1959 until the mid-1970s, where she led the Software Engineering Division. Her team wrote and tested all the on-board flight software for Apollo 11, which carried Neil Armstrong and Buzz Aldrin to the first Moon landing in July 1969.

"I was attracted both by the sheer idea and the fact that it had never been done before," she told the Guardian in 2019. "I was the first programmer to join and the first woman they hired."

She is credited with coining the term "software engineering", at a time when writing code was often dismissed as less serious than building hardware. She wanted the discipline to be given the same respect as other branches of engineering.

Minutes from disaster

Her team's work was tested in the most dramatic way possible. Moments before Apollo 11 touched down, the lunar module's computer began raising alarms, signalling that it was overloaded.

For a moment it looked as though the landing might have to be abandoned. But Hamilton and her team had anticipated such a problem, designing "priority-driven software" that shut down less important tasks and kept the computer focused on the most important job: landing on the Moon.

The Eagle landed safely, and Armstrong and Aldrin stepped into history.

The famous photograph

Her achievement was immortalised in a 1969 photograph showing Hamilton standing beside a stack of printed code as tall as she was. The image has become one of the most celebrated pictures in the history of computing, and a symbol of women's often-overlooked role in the space race.

In 2016, President Barack Obama awarded her the Presidential Medal of Freedom, the highest civilian honour in the United States. He said she "symbolises that generation of unsung women who helped send humankind into space".

From Indiana to the Moon

Hamilton was born in Indiana in 1936. She studied mathematics at the University of Michigan in 1955 before moving to Earlham College, where she earned a degree in mathematics in 1958.

A year later she moved to Boston with her husband, intending to study further, but took a job at MIT that would change the course of her life — and of space exploration.

After leaving MIT she founded her own software companies, continuing to develop ideas about how to build reliable systems that prevent errors before they happen.

A lasting legacy

Today, software controls aircraft, hospitals, power grids and the phones in billions of pockets. The principles Hamilton championed — rigorous testing, anticipating failure and designing systems that can recover — are at the heart of modern engineering.

Her work fed directly into later missions, including the Apollo flights that followed and the software principles later adopted for Skylab and the Space Shuttle programme.

Her story has inspired generations of girls and women to enter computing, a field in which they remain under-represented.

Tributes poured in from scientists, engineers and astronauts, many describing her as a hero who proved that software could be as vital to exploration as rockets and spacecraft.

When the world watched the first Moon landing, few knew the name of the young programmer whose code had kept it on course. More than half a century later, Margaret Hamilton is remembered as one of the people who made it possible.