"Today, I am humbled to announce that after 25 years of service to our country, I am retiring from the United States Navy and leaving NASA, effective Oct. 1," Kelly, 47, said in a statement posted on Facebook.
In a NASA career that began in 1996, Kelly has taken part in four shuttle flights, two each in shuttles Endeavour and Discovery, SPACE.com reported.
Giffords shot in the head during an assassination attempt at a constituent meeting in Tucson in January, underwent surgeries and intense rehabilitation and was able to travel to Florida for Kelly's May 16 launch in Endeavour.
While NASA had originally named a backup commander for the flight, Kelly was able to resume his training as his wife's condition improved.
"I will be forever grateful to the NASA managers who trusted me with this enormous responsibility during such a difficult period in my personal life and to those leaders in the United States Navy who prepared me to handle these challenging times," Kelly said.
"Gabrielle is working hard every day on her mission of recovery," he said. "I want to be by her side. Stepping aside from my work in the Navy and at NASA will allow me to be with her and with my two daughters."
Rosie O'Donnell unveils nearly 50-pound weight loss
Disney's 'Jessie' to feature network's first engagement