(CNN) John Glenn , the first American to orbit the Earth and a longtime US senator, died Thursday, according to the Ohio State University . He was 95.

It was announced Wednesday that Glenn had been hospitalized "more than a week ago," according to Ohio State University spokesman Hank Wilson. He was at the James Cancer Hospital at the Ohio State University, but his illness was not disclosed.

Glenn had heart valve replacement surgery in 2014.

We are saddened by the loss of Sen. John Glenn, the first American to orbit Earth. A true American hero. Godspeed, John Glenn. Ad astra. pic.twitter.com/89idi9r1NB

"With John's passing, our nation has lost an icon and Michelle and I have lost a friend," Obama said. "John spent his life breaking barriers, from defending our freedom as a decorated Marine Corps fighter pilot in World War II and Korea, to setting a transcontinental speed record, to becoming, at age 77, the oldest human to touch the stars. John always had the right stuff, inspiring generations of scientists, engineers and astronauts who will take us to Mars and beyond -- not just to visit, but to stay. ...

"The last of America's first astronauts has left us, but propelled by their example we know that our future here on Earth compels us to keep reaching for the heavens."

NASA Administrator Charles Bolden called Glenn a mentor, role model and dear friend.

"Glenn's extraordinary courage, intellect, patriotism and humanity were the hallmarks of a life of greatness," Bolden said. "His missions have helped make possible everything our space program has since achieved and the human missions to an asteroid and Mars that we are striving toward now."

Saddened to hear of losing my friend and world space icon John Glenn. Here's my official statement. https://t.co/j5ScHMp132 pic.twitter.com/NBmi2z1G3b — Buzz Aldrin (@TheRealBuzz) December 9, 2016

Former Apollo astronaut Buzz Aldrin said he was saddened by the loss of a "space pioneer and world icon."

"I am very sorry that he has departed us with his wisdom. I join that crowd of people and the entire nation and the world in paying homage to his service," said Aldrin from a hospital bed where he has been since he was evacuated recently from the South Pole

Social media was flooded with remembrances and reactions immediately after news of Glenn's death.

Today we lost a great pioneer of air and space in John Glenn. He was a hero and inspired generations of future explorers. He will be missed. — Donald J. Trump (@realDonaldTrump) December 8, 2016

Today, we join the world in mourning the passing of legendary astronaut, senator and Ohioan John Glenn. https://t.co/L66WmMJgHi pic.twitter.com/ny3NPpm0nk — Ohio State (@OhioState) December 8, 2016

Aren't many Heroes left: WWII & Korean War Fighter Pilot. Marine Colonel. NASA Astronaut. Senator. Married 73 yrs. John Glenn RIP 1921-2016 — Neil deGrasse Tyson (@neiltyson) December 8, 2016

A fascination with flight

John Herschel Glenn Jr. made history in 1962 when he completed a three-orbit flight in a cramped space capsule dubbed Friendship 7. He later served for nearly a quarter century as a US senator. In 1998, he returned to space at age 77, becoming the oldest person to ever do so.

Born in the small eastern Ohio town of Cambridge on July 18, 1921, Glenn recounted an idyllic childhood where "patriotism filled the air."

Photos: John Glenn: Ex-astronaut, US senator dies at 95 John Glenn, the former astronaut and US senator from Ohio, died Thursday, December 8 , according to Ohio State University. He was 95. Glenn became the first American to orbit the Earth in 1962. Hide Caption 1 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn, here in a family photo at 4 months old, was born July 18, 1921, in Cambridge, Ohio. Hide Caption 2 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 During World War II, Glenn enlisted in the Naval Aviation Cadet Program in 1942 and became a pilot for the US Marines a year later. Glenn, pictured here in the cockpit of an F-8 fighter, completed nearly 150 combat missions in World War II and the Korean War. Hide Caption 3 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 In 1957, Glenn, then a Marine major, set the transcontinental air speed record, flying a Vought F-8 Crusader from Los Angeles to New York in three hours and 23 minutes. He became known as one of the top test pilots in the United States and a natural candidate for the emerging space program. Hide Caption 4 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn's family -- wife Annie, daughter, Carolyn "Lyn" and son David -- greet him at Floyd Bennett Field in New York after his record-breaking transcontinental flight. Hide Caption 5 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn and his wife, Annie, sandwich their daughter, Carolyn "Lyn," as they embrace following a ceremony honoring his feat. Son David is at left. Hide Caption 6 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn receives a Distinguished Flying Cross from then-Navy Secretary Thomas Gates at the Pentagon. Hide Caption 7 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 In 1959, NASA selected seven men -- from left, Wally Schirra, Alan Shepard, Gus Grissom, Deke Slayton, Glenn, Scott Carpenter and Gordon Cooper -- as the first US astronauts, known as the Mercury 7. Hide Caption 8 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn, now a Project Mercury astronaut, is seen through fisheye lens during training in a mock-up of a space capsule. Hide Caption 9 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn, third from left, and the six other Mercury 7 astronauts participate in US Air Force survival training exercises in 1960 in Nevada. The training was intended to prepare the astronauts in case of an emergency or faulty landing in a remote area. Hide Caption 10 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 The astronauts instantly became national heroes and media sensations. Decades later they were immortalized in the Tom Wolfe best-seller "The Right Stuff" and subsequent film. Hide Caption 11 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn prepares for the Mercury-Atlas 6 flight. He would becomes the third American in space. Hide Caption 12 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn inspects artwork to be painted on the outside of his Mercury spacecraft, which he nicknamed Friendship 7. On February 20, 1962, Glenn became the first American to orbit the Earth. After orbiting the Earth three times in four hours and 55 minutes, the Friendship 7 landed in the Atlantic Ocean. Hide Caption 13 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Following his Mercury flight, Glenn and his wife, Annie, join Vice President Lyndon Johnson in the front car of a New York motorcade parade honoring the astronaut. An estimated 4 million people turned out for the March 1, 1962, ticker-tape parade. Hide Caption 14 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 The famed astronaut addresses a joint session of Congress on February 28, 1962. Hide Caption 15 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn holds his discharge papers after he retired from the Marine Corps and resigned from NASA's astronaut program. Now a national figure, he went on to become an executive for the Royal Crown Cola Co. He would soon explore a career in politics. Hide Caption 16 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn and his family celebrate his November 1974 election win as US senator from Ohio. He began a 24-year career on Capitol Hill and was widely regarded as an effective legislator and moderate Democrat. He unsuccessfully sought the Democratic presidential nomination in 1984. Hide Caption 17 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 On October 29, 1998, Glenn, then 77, became the oldest person to venture into space. Here, he has his flight suit checked before climbing into the space shuttle Discovery. His second flight into space came 36 years after his legendary Mercury launch. Hide Caption 18 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn is seen aboard the shuttle Discovery in 1998. He was a STS-95 payload specialist on the nine-day mission. Hide Caption 19 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn joins former President Bill Clinton in Marion, Ohio, during a campaign stop for Hillary Clinton during her 2008 presidential campaign Hide Caption 20 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 Glenn displays his Congressional Gold Medal with Sens. Harry Reid, left, Bill Nelson, second from right, and Mitch McConnell during a ceremony in the Capitol Rotunda in November 2011. Hide Caption 21 of 22 Photos: John Glenn: Ex-astronaut, US senator dies at 95 President Barack Obama presents Glenn with the Presidential Medal of Freedom during a May 2012 ceremony at the White House. Hide Caption 22 of 22

"Love of country was a given. Defense of its ideals was an obligation," Glenn wrote in his memoir. "The opportunity to join in its quests and explorations was a challenge not only to fulfill a sacred duty but to join a joyous adventure."

Glenn developed a fascination with flying at an early age. When he was 8 years old, he and his father went for a ride in an open-cockpit biplane, two years after Charles Lindbergh made his transatlantic flight. That adventure sealed his destiny as a pilot.

He also developed an early love for childhood playmate Anna Margaret Castor. By the time they got to high school, they were sweethearts. Both were in Muskingum College in New Concord, his mother's alma mater, when Japanese forces attacked Pearl Harbor on December 7, 1941. A short time later, Glenn enrolled in the Naval Aviation Cadet Program and graduated the following March. He joined the Marine Corps in early 1943 and wed his childhood sweetheart on April 6 of that year.

Glenn flew 149 combat missions in World War II and the Korean War. In the final nine days of the Korean War, Glenn shot down three MiG fighter jets along the Yalu River. His military service earned him numerous awards, including six Distinguished Flying Crosses.

After Korea, Glenn became a test pilot for naval and Marine aircraft and, in 1957, set the transcontinental air speed record. He flew a Vought F-8 Crusader from Los Angeles to New York in three hours and 23 minutes -- the first transcontinental flight to average supersonic speed.

With that feat, Glenn became known as one of the top test pilots in the United States and a natural candidate for the country's emerging space program.

'The Right Stuff'

He eagerly volunteered when NASA requested pilots for its suborbital and orbital programs, and in 1959 he and six others -- Alan Shepard, Gus Grissom, Scott Carpenter, Wally Schirra, Gordon Cooper and Deke Slayton -- were selected as the first astronauts, known as the "Mercury 7." Glenn was the last living member of the group.

The men instantly became national heroes and media sensations.

On February 20, 1962, Glenn rode an Atlas rocket into history as the first American to orbit the Earth. He was the third American in space, behind Shepard and Grissom -- whose missions aboard smaller Redstone rockets were short suborbital flights. The Soviet Union by that time had sent two cosmonauts, Yuri Gagarin and Gherman Titov, on orbital flights.

After making three orbits in four hours and 55 minutes, Glenn landed in the waters off Grand Turk Island in the Atlantic Ocean, 800 miles southeast of Bermuda, where he and his Friendship 7 were retrieved by the destroyer USS Noa.

Saddened by the loss of my former astronaut colleague John Glenn. Was very honored to have known him. #Godspeed, John Glenn. pic.twitter.com/IRKGJNqYJQ — Scott Kelly (@StationCDRKelly) December 8, 2016

Glenn recalled in a Life magazine article a strange phenomenon that occurred during the mission: "There, spread out as far as I could see were literally thousands of tiny luminous objects that glowed in the black sky like fireflies. I was riding slowly through them, and the sensation was like walking backwards through a pasture where someone had waved a wand and made all the fireflies stop right where they were and glow steadily."

The flight also featured a glitch that contributed to Glenn's reputation for being cool under fire.

Because of an indicator light showing that the Mercury capsule's heat shield was partly detached, mission controllers decided to bring Glenn home early and told him not to jettison his aft retro rockets, which allowed him to maneuver the craft in space. Because the retropack was strapped to the heat shield, it was thought it would provide an extra measure of security.

It would later be learned that the heat shield wasn't damaged, but the fiery re-entry was made more spectacular by the scorching retropack in Earth's upper atmosphere. Glenn's first words when he stepped aboard the deck of the USS Noa were, "Boy, that was a real fireball of a ride!"

Later in life, Glenn poked fun at the risk.

"We used to joke about it in the past when people would say, 'What do you think on the launch pad?' " he said in a 1998 CNN interview.

"And the standard answer was, 'How do you think you'd feel if you knew you were on top of 2 million parts built by the lowest bidder on a government contract?' "

Glenn's mission was more than just a round-the-world space journey. It was a psychological boost to a nation worried about the Soviet Union's early lead in the space race.

Shortly after landing, Glenn was honored with an enormous ticker tape parade in New York City on March 1, 1962. An estimated 4 million people turned out.

His success bolstered America's spirit and gave credence to President John Kennedy's 1961 pledge to put men on the moon. But Glenn would not be one of them.

Kennedy reportedly ordered NASA not to fly Glenn again because he was too valuable as a national figure. Glenn resigned from the space agency in January 1964.

Political career

Glenn's fame made him a natural candidate for political office, and shortly after his resignation from NASA, he announced he would run for the Democratic ticket for a US Senate seat in 1964. But his political career was sidelined for a few years when an injury forced him to withdraw from the campaign.

Glenn then joined Royal Crown Cola as a vice president and later as president. Yet he remained interested in politics. He was also a close friend of the Kennedy family. On June 5, 1968, Glenn was with Sen. Robert Kennedy at the Ambassador Hotel in Los Angeles, hours before Kennedy was shot by Sirhan Sirhan. Kennedy died the next day.

"Who knows what might have happened if Bobby had been president," Glenn reflected shortly after his 90th birthday, in a 2011 interview with the Dayton Daily News.

"I know he had just about more compassion for the underdog, for the poor, the downtrodden than, I think, just about anybody that I ever knew."

After a failed bid for a US Senate seat in 1970, Glenn won in 1974, beginning a 24-year career representing Ohio on Capitol Hill. He was widely regarded as an effective legislator and moderate Democrat. He played a key role in weapons control, authoring the Nuclear Nonproliferation Act of 1978, which prohibited the sale of nuclear equipment to nations that currently have none.

Glenn -- along with fellow Mercury 7 astronauts Grissom and Shepard -- was awarded the Congressional Space Medal of Honor in 1978 by then-President Jimmy Carter.

More than 20 years after their historic missions, the team was immortalized in the 1983 movie "The Right Stuff." Glenn -- portrayed by Ed Harris -- didn't care much for the film, saying, "I thought it was dramatic enough without Hollywood doing its number on it."

Despite his rock-solid reputation as an American icon, not everything went perfectly for Glenn. In 1984, he decided to run for president, confidently declaring, "With the nomination of my party I firmly believe I can beat Ronald Reagan."

He was knocked out of the primaries early on.

A return to space

As he grew older, Glenn never gave up his dream of flying in space again or, as he called it in the Mercury days, being "a willing guinea pig."

At age 77, a year after retiring from the Senate, Glenn accepted an invitation from NASA to rejoin the space program as a member of space shuttle Discovery on a nine-day mission to study the aging process, which mirrors what astronauts experience during long durations in space.

On October 29, 1998, Glenn became the oldest human ever to venture into space, and his flight proved once again that he was a man who embraced a challenge.

For most men and women, fame is fleeting and greatness is short-lived. For John Herschel Glenn Jr., it lasted a lifetime.

Glenn is survived by his wife of 73 years, Annie; his two children, John David and Carolyn Ann (Lyn); and two grandchildren.