Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

ALBUQUERQUE, N.M. — In 1959, Ronald Erwin McNair walked into a South Carolina library. The 9-year-old aspiring astronaut wanted to check out a calculus book, but a librarian threatened to call the police if he didn’t leave. McNair was black.

Years later, McNair was selected to become only the second African American to travel to space, overcoming segregation, poverty, and stereotypes in an intellectual act of resistance that inspired a generation. Tragically, McNair died in the 1986 Space Shuttle Challenger tragedy.

McNair’s story and those of other black astronauts are shared in a new documentary that looks at the final frontier of civil rights: getting black astronauts into space amid Jim Crow, danger, discrimination and the Cold War. Within four generations, they went from slavery to space.

“Black in Space: Breaking the Color Barrier,” scheduled to air this month on the Smithsonian Channel, examines the race to get black astronauts into the heavens while fighting for human rights on earth. It shows how the astronauts surmounted racial barriers and hostile commanders to get close to the stars.

Guion Bluford would become the first African American astronaut. The aerospace engineer made it to space in 1983 as a member of the crew of the Orbiter Challenger. His trip came nearly 20 years after Kennedy sought to get a black man in space.

“They really are the first of the first,” filmmaker Laurens Grant said. “And they are the elite of the elite.”

Not only did these aspiring space travelers have to navigate the racial politics of their time, they also had to study cutting-edge science and engineering to compete with others, Grant said.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

And it didn’t always end happily.

The road to get black astronauts into space in the U.S. began under President John. F. Kennedy. His brother, Attorney General Robert Kennedy, pressured an Air Force program to make sure its astronaut project had a person of color.

Air Force Capt. Ed Dwight was selected for a trainee program and became an overnight hero in the black press. However, the NASA program did not select him for the astronaut program.

U.S. Air Force officer Robert Henry Lawrence Jr. was chosen. NASA selected the Chicago-born Lawrence as the first African American astronaut, and he may have made it to the moon. Unfortunately, Lawrence died after his F-104 Starfighter crashed in 1967 at Edwards Air Force Base, California,

No African Americans would make it to the moon.

During this era, Star Trek Communication Officer Lieutenant Uhura, played by Nichelle Nichols in the 1960s NBC television series, got the closest even though she was a fictional character. She would later speak out in public service announcements to recruit black scientists and pilots to NASA.

Frederick Gregory, now 79, saw some of those ads.

“She was inside my TV one morning. She pointed at me and said, ‘I want you to apply for the NASA program,’” Gregory said. “She was talking to me.”

The U.S. Air Force pilot would apply and later become the first African American shuttle pilot.

The film shows how the former Soviet Union beat the U.S. and sent into space Cuban cosmonaut Arnaldo Tamayo Méndez. He was the first Latin American and first person of African descent to reach space. After his mission, he became a Cold War hero for Cuba — and his accomplishment was largely ignored.

Gregory said he’s proud of his role in breaking barriers and contributing to space exploration. However, he’s now concerned about what comes next.

In an interview with The Associated Press, Gregory said he recalls looking down at Earth while floating in space and traveling at high speed.

“Your concept of neighbor changes significantly,” Gregory said. “I began saying, ‘Hey, this is a world, and we are all part of it.’ When you go to space, you don’t see boundaries on the ground. You wonder, why do these people dislike each other. Your concept of what your home is changes.”