NEW YORK — Together and apart, the lives of Gabrielle Giffords and husband-astronaut Mark Kelly have been extraordinary.

She the congresswoman from Arizona who has miraculously survived being shot in the head. He the commander of the space shuttle Endeavour, exchanging wedding rings with his wife before his final mission in space. Now, he is retiring to be with her full time and the two are collaborating on a memoir that will tell a story, their story, that Kelly says the public hardly knows.

The book, currently untitled, will be an intimate chronicle of everything from their careers and courtship to the Jan. 8 tragedy when a gunman shot Giffords during a political event in Tucson, Ariz. Six people were killed in the attack and 12 others besides the congresswoman were wounded. Scribner will publish the book at a date to be determined.

Because of rules covering members of the House of Representatives, Giffords will not receive an advance against royalties and the deal must be cleared by the House ethics committee. Royalties derived from book sales are permitted, a portion of which will be donated to charities that benefit Tucson and Arizona. The percentage being donated and the specific charities have yet to be determined.

"Since Jan. 8, it's been really touching to us to see how much support there is for Gabby and her recovery, and how much interest there is in how she's doing and her story," Kelly, a Navy captain, told The Associated Press during a recent interview from Texas.

"After thinking about it, and talking about it, we decided it was the right thing to do to put our words and our voices on paper and tell our story from our point of view."

The 47-year-old Kelly announced his retirement Tuesday on Facebook. Most recently, he was commander of the Endeavour's final mission, which ended June 1. Kelly's decision is not surprising. NASA is retiring its space shuttle fleet in just another month, and it will be years before the United States has another spacecraft for astronauts to fly.

"As life takes unexpected turns we frequently come to a crossroads. I am at this point today," Kelly, whose retirement is effective Oct. 1, wrote on Facebook. "Gabrielle is working hard every day on her mission of recovery. I want to be by her side."

Giffords, 41, was released from a Houston hospital last week and is set to start outpatient therapy. She had been in the rehab facility since late January, a few weeks after the shooting, and is now living with Kelly at his home in League City, a town 26 miles south of Houston. She will continue outpatient therapy at TIRR Memorial Hermann, the same hospital where she underwent rehabilitation.

Giffords has not announced when, or if, she'll return to Congress or whether she'll seek re-election.

Kelly and Giffords are collaborating with author Jeffrey Zaslow, who worked on Randy Pausch's million-selling "The Last Lecture" and Capt. Chesley "Sully" Sullenberger's "Highest Duty." Kelly praised Zaslow as a "good storyteller" and "the best writer" for the kind of book they wanted. Zaslow will interview friends, family members and colleagues of Kelly and Giffords.

"There are details of our personal lives together that I'd say I can count on one hand the people who know them. In some cases, it's just Gabby and I (who know the details)," Kelly said.

The couple met in China in 2003 during a young leaders' forum and married in November 2007 after a long-distance romance. There marriage was long-distance, too. Kelly lived in Houston, NASA's astronaut base. Giffords split her time between Washington and Tucson with frequent visits to Texas to see her husband.

Kelly rushed by private jet from Houston to Tucson when he learned of the assassination attempt. While Giffords was in rehab, Kelly would care for her in the early mornings, taking her a newspaper and a cup of her favorite nonfat latte with cinnamon on top. He would train for his mission throughout the day, then return to his wife at night.

Giffords will focus on her recovery, but Kelly said that the book will be part of that process and that Giffords will provide details of what "she remembers after Jan. 8 and her story before that." While Kelly will be "the primary collaborator," he said Giffords will be a "big part" of the project. Giffords has been struggling to relearn how to speak and walk, and will be assisted by a 24-hour home health provider, according to the hospital.

Kelly, a former combat pilot, flew four times on space shuttles, more than many astronauts ever hope to do. The Endeavour's final voyage was a high-profile mission that included four spacewalks and delivery of a $2 billion cosmic ray detector to the International Space Station. His identical twin, Scott, also part of NASA's 1996 astronaut class, returned from a five-month stay at the International Space Station in March.

For the book deal, Kelly and Giffords were represented by Washington attorney Robert Barnett, whose clients include President Obama and Secretary of State Hillary Rodham Clinton. The memoir will be edited at Scribner by executive vice president and publisher Susan Moldow, and senior vice president and editor-in-chief Nan Graham.

"I really felt a connection with them and I knew Gabby would, too," Kelly said. "Gabby is very pro-women and she always has been. And I knew after meeting Susan and Nan that they were definitely the right people to work with."