Neil Armstrong, photographed inside the lander after the moonwalk on July 20, 1969

His family said he died of complications “resulting from cardiovascular procedures.” He had undergone heart bypass surgery this month in Cincinnati, near where he lived. The family did not say where he died.

In a statement from the White House, President Obama said, “Neil was among the greatest of American heroes.”

“And when Neil stepped foot on the surface of the moon for the first time,” the president added, “he delivered a moment of human achievement that will never be forgotten.”

A quiet, private man, at heart an engineer and crack test pilot, Mr. Armstrong made history on July 20, 1969, as the commander of the Apollo 11 spacecraft on the mission that culminated the Soviet-American space race in the 1960s. President John F. Kennedy had committed the nation to sending men to the moon in that decade, and the goal was met with more than five months to spare.

On that day, Mr. Armstrong and his co-pilot, Col. Edwin E. Aldrin Jr., known as Buzz, steered their lunar landing craft, Eagle, to a level, rock-strewn plain near the southwestern shore of the Sea of Tranquillity. It was touch and go the last minute or two, with computer alarms sounding and fuel running low. But they made it.

“Roger, Tranquility,” mission control replied. “We copy you on the ground. You’ve got a bunch of guys about to turn blue. We’re breathing again. Thanks a lot.”

The same could have been said for hundreds of millions of people around the world watching on television.

A few hours later, there was Mr. Armstrong bundled in a white spacesuit and helmet on the ladder of the landing craft. Planting his feet on the lunar surface, he said, “That’s one small step for man, one giant leap for mankind.” (His words would become the subject of a minor historical debate, as to whether he said “man” or “a man.”)

Soon Colonel Aldrin joined Mr. Armstrong, bounding a little like kangaroos in the low lunar gravity, one sixth that of earth’s, while the command ship pilot, Michael Collins, remained in orbit about 60 miles overhead, waiting their return. In all, 12 American astronauts walked on the moon between then and the Apollo 17 mission in 1972.

The Apollo 11 mission capped a tumultuous and consequential decade. The ’60s in America had started with such promise, with the election of a youthful president, mixed with the ever-present anxieties of the cold war; then it touched greatness in the civil rights movement, only to implode in the years of assassinations and burning city streets and campus riots. But before it ended, human beings had reached that longtime symbol of the unreachable.

The moonwalk lasted two hours and 19 minutes, long enough to let the astronauts test their footing in the fine and powdery surface — Mr. Armstrong noted that his bootprint was less than an inch deep — and set up a television camera and scientific instruments and collect rock samples.

“As long as there are history books,” said Charles F. Bolden Jr., the current NASA administrator, “Neil Armstrong will be included in them, remembered for taking humankind’s first small step on a world beyond our own.”

Mr. Bolden also noted that in the years after the moonwalk, Mr. Armstrong “carried himself with a grace and humility that was an example to us all.” The historian Douglas Brinkley, who interviewed Mr. Armstrong for a NASA oral history, described him as “our nation’s most bashful Galahad.”

Indeed, some space officials have cited these characteristics, as well as his engineering skills and experience piloting X-15 rocket planes, as reasons Mr. Armstrong stood out in the astronaut corps. After the post-flight parades and a world tour for the three Apollo 11 astronauts, Mr. Armstrong gradually withdrew from the public eye. He was not reclusive, but as much as possible he sought to lead a private life, first as an associate administrator in the space program, then as a university professor and director of a number of corporations.

Neil Alden Armstrong was born on Aug. 5, 1930, in the small town of Wapakoneta, Ohio, to Stephen Armstrong and the former Viola Louise Engel. His father was a state auditor, which meant the family moved every few years to a new Ohio town while Neil was growing up. At the age of six, his father and Neil took a ride in a Ford Trimotor airplane, known as the Tin Goose. It must have made an impression, for by the time he was 15, he had learned to fly, before he got his driver’s license.

By the time Neil had become an Eagle Scout, the family had moved back to Wapakoneta, where he finished high school. (The town now has a museum named for Mr. Armstrong.) From there he went to Purdue University as an engineering student on a Navy scholarship. His college years were interrupted by the Korean War, in which Mr. Armstrong was a Navy fighter pilot who flew 78 combat missions, one in which he was forced to eject after the plane lost one of its ailerons, the hinged flight-control panels on the wings.

In “First Man: The Life of Neil Armstrong,” James R. Hansen wrote that in Mr. Armstrong’s first year at Purdue, Charles E. Yeager broke the sound barrier in the rocket-powered Bell X-1. It was exciting but bittersweet for the young student. He thought aviation history had already passed him by.

“All in all, for someone who was immersed in, fascinated by, and dedicated to flight,” Mr. Armstrong told his biographer, “I was disappointed by the wrinkle in history that had brought me along one generation late. I had missed all the great times and adventures in flight.”

During Korean War, Mr. Armstrong was in the unit that the author James A. Michener wrote of in “The Bridges at Toko-Ri.” Back at Purdue after the Navy, Mr. Armstrong plunged more earnestly into aeronautical engineering studies, his grades rising and a career in sight.

By this time, he had also met Janet Elizabeth Shearon, a student in home economics from Illinois. Soon after his graduation, they were married in January 1956.

They had two sons, Eric and Mark, who survive. A daughter, Karen, died of an inoperable brain tumor in 1962. The couple were divorced in 1994; Janet Armstrong lives in Utah. Mr. Armstrong married Carol Knight, a widow 15 years his junior, in 1999, who also survives. They lived in Indian Hills, a suburb of Cincinnati.

After his first marriage, the newly weds moved to California, where Mr. Armstrong had been hired as an experimental test pilot at Edwards Air Force Base. His first flight in a rocket plane was in the Bell X 1B, a successor to the plane Mr. Yeager had first flown faster than the speed of sound.

Mr. Armstrong impressed his peers. Milt Thompson, one of the test pilots, said he was “the most technically capable of the early X-15 pilots.” Another colleague, Bill Dana, said he “had a mind that absorbed things like a sponge and a memory that remembered them like a photograph.” He made seven X-15 flights to the edge of space.

In 1958, Mr. Armstrong was chosen as a consultant for a military space plane project, the X-20 Dyna-Soar, and later was named as one of the pilots. But the young test pilot was attracted by another opportunity. NASA was receiving applications for the second group of astronauts, after the Mercury seven. His reputation after seven years at the NASA flight center at Edwards had preceded him, and so he was tapped for the astronaut corps.