It was the spring of 1961. President John F. Kennedy, speaking of new frontiers and projecting the vigor of youth, had been in office barely four months, and April had been the cruelest.

On the 12th, Yuri Gagarin became the first human to orbit Earth — one more space triumph for the Soviet Union. Though the flight was not unexpected, it was nonetheless deflating; it would be more than a month before Alan Shepard became the first American in space, and that was on a 15-minute suborbital flight. On the 17th, a force of anti-Castro exiles, trained by the C.I.A., invaded communist Cuba at the Bay of Pigs — a fiasco within 36 hours. Mr. Kennedy’s close aide Theodore Sorensen described him on the 19th as “anguished and fatigued” and “in the most emotional, self-critical state I had ever seen him.”

At one meeting, his brother Robert F. Kennedy, the attorney general, “turned on everybody,” it was reported, saying: “All you bright fellows. You got the president into this. We’ve got to do something to show the Russians we are not paper tigers.” At another, the president pleaded: “If somebody can, just tell me how to catch up. Let’s find somebody — anybody. I don’t care if it’s the janitor over there.” Heading back to the Oval Office, he told Mr. Sorensen, “There’s nothing more important.”

So, 50 years ago, on May 25, 1961, President Kennedy addressed a joint session of Congress and a national television audience, declaring: “I believe that this nation should commit itself to achieving the goal, before this decade is out, of landing a man on the moon and returning him safely to Earth.”