Credit...William P. Straeter/Associated Press

Jerrie Cobb was as qualified as any man to be an astronaut.

A seasoned pilot, she held world records for speed, altitude and distance. She had undergone rigorous physical and psychological examinations and emerged in the top 2 percent of all those — mostly men — who were tested.

But in 1961, as she seemed on the verge of becoming the nation’s first female astronaut, the door was slammed shut.

“Right Stuff, Wrong Sex” was the title of a 2005 book about her plight and that of a dozen other women, all pilots, who had also passed the required tests but were barred from the elite astronaut corps.

Ms. Cobb, who died on March 18 at her home in Florida at 88, would fight her exclusion for years to come.

She even went up against no less a symbol of the space age and its masculine ethos than John Glenn, one of the original Mercury Seven astronauts and the first American to orbit Earth.

The scene was a hearing room on Capitol Hill in 1962, when members of Congress were considering whether women could be astronauts. At the time, astronauts were drawn from the pool of test pilots, which was reserved for men.

“We women pilots who want to be part of the research and participation in space exploration are not trying to join a battle of the sexes,” Ms. Cobb testified. “We see, only, a place in our nation’s space future without discrimination.”

Mr. Glenn, a fighter pilot in World War II and a future senator from Ohio, testified the next day. “The men go off and fight the wars and fly the airplanes and come back and help design and build and test them,” he said. “The fact that women are not in this field is a fact of our social order.”

And, for the next two decades, that was more or less that.

Not until 1983, when Sally Ride soared into space on the shuttle Challenger, would an American woman escape Earth’s gravity. A Soviet cosmonaut, Valentina Tereshkova, had long before become the first woman in space, in 1963.

Ms. Cobb, who had been flying since the age of 12, was deeply disappointed. She would turn her energies to flying humanitarian missions in the Amazon jungle, delivering medicine, food and clothing to isolated indigenous tribes. Her work earned her a nomination for the Nobel Peace Prize in 1981. And she was honored by the governments of Ecuador, Brazil, Colombia and Peru.

“Typically flying solo in her Aero Commander, she pioneered new air routes across the hazardous Andes Mountains and Amazon rain forests,” according to the National Aviation Hall of Fame, which inducted her in 2012.

But the possibility of going into space tugged at her. She saw the chance to make one last pitch in 1998, when NASA announced that it was sending Senator Glenn back into space at the age of 77 to test the effects of weightlessness on the aging human body.

“I would give my life to fly in space,” Ms. Cobb, then 67, told The Associated Press.

Again, NASA turned her down.

Ms. Cobb remains a major figure in aviation history. She was even immortalized in a recent Off Broadway drama called “They Promised Her the Moon.”

“It’s a tragic story,” Laurel Ollstein, the playwright, told Space.com in 2017. “But it’s also a story of so many women who are unbelievably capable and then, just because they’re women, aren’t able to go as far as they could.”

Geraldyn M. Cobb was born on March 5, 1931, in Norman, Okla., the daughter of Lt. Col. William Cobb, who was known as Harvy, and Helena (Stone) Cobb. During World War II the family was stationed at Sheppard Field in Wichita Falls, Tex., where Ms. Cobb flew for the first time in her father’s 1936 Waco aircraft.

“Soaring above the earth gave the shy girl a confidence she didn’t feel on the ground,” the Hall of Fame said. She earned her solo pilot’s license at 16 and had both her private and commercial pilot’s licenses by 20.

She attended Oklahoma College for Women (now the University of Science and Arts of Oklahoma) for one year but spent most of her time at Chickasha Municipal Airport doing general maintenance work and flying as a crop duster or on pipeline patrol.

At one point she headed to Florida for what she thought was a job as a DC-3 co-pilot but was rejected when the airline discovered that Jerrie Cobb was not a man. She got a job at an aircraft maintenance shop — as a typist and file clerk.

She eventually found work as a pilot for an international aircraft ferry service and spent the next three years delivering aircraft, B-17 bombers and the like, around the world.

By age 28, in 1959, she had logged 7,000 hours in the cockpit. At that point she was approached by William Randolph Lovelace, a research scientist for NASA, who had tested the Mercury Seven astronauts. He suggested that she take the space stress test.

Dr. Lovelace, who specialized in aerospace medicine, believed that women would make excellent astronauts. They generally weighed less than men and were shorter, so they would need less oxygen and less food and water. He also thought they were more resistant to radiation, less prone to heart attacks and better suited to handling pain, heat, cold and loneliness.

Ms. Cobb jumped at the chance to participate and helped locate other women who, as pilots, seemed like astronaut material.

But partway through the process, which had not been officially authorized by NASA, the testing of the women was abruptly canceled. Ms. Cobb tried to get to the bottom of what had happened, without luck.

Around the same time, young women — including the future Hillary Clinton — were writing letters to NASA asking how they could become astronauts. The replies said essentially that NASA had no programs for women and did not plan to start any.

The closed door prompted Ms. Cobb and other women to lobby for the 1962 congressional hearings.

“She identified sexism at NASA, and there wasn’t a legal redress for it until the 1964 Civil Rights Act,” Margaret Weitekamp, the author of “Right Stuff, Wrong Sex: America’s First Women in Space Program” (2005) and a curator at the Smithsonian Institution’s National Air and Space Museum, said in a telephone interview.

But her timing was against her. Just months before the hearings, Mr. Glenn had returned from orbiting Earth to a hero’s welcome, and President John F. Kennedy had set the nation’s sights on going to the moon.

NASA was consumed with that goal and did not want the distraction of a debate over whether women could be astronauts.

Ms. Cobb’s death was announced in a statement by her family posted on the website Spaceref on Thursday. It did not give the cause of death, list survivors or say where in Florida she died.

Despite her disappointments, Ms. Cobb remained fascinated by space travel. On July 20, 1969, she listened on the radio as Neil Armstrong and Buzz Aldrin landed on the moon.

Alone in the Amazon, she danced on the wings of her plane in the moonlight.