Kelly is suffering from squamous cell carcinoma, but he has recently undergone tests to show that the cancer is isolated in his jaw and has not spread to other parts of his body.
"The past couple of weeks have been difficult for me," Kelly said. "Because of the nature of social media, I thought it would be best to share with everyone what has been going on with my health."
The announcement was made Monday morning, just before the start of the quarterback's Kelly For Kids charitable foundation's annual celebrity golf tournament.
"Doctors have told me that my prognosis for recovery is very good," he said.
Kelly will have part of the upper jaw removed, and he is unsure whether he will require chemotherapy, which will be determined after surgery. The operation will be performed in Buffalo.
"We caught it in time," Kelly said. "When you hear the word 'cancer,' it automatically scares you. It not only scared me, but my family. But it's like everything. It's another river to cross, another stumbling block. I've been to the top many times. And I've been to the bottom. It's just one of the roller coaster rides I've been on throughout my life.
"It's just another challenge for me and I know I'll beat it."
Kelly spent 11 seasons with the Bills before retiring following the 1996 campaign. He still holds nearly every significant career franchise passing record -- 35,467 yards, 237 touchdowns and 26 300-yard games -- and was inducted into the Pro Football Hall of Fame in 2002.
"I am extremely confident in my road to recovery," Kelly said. "I plan to tackle this challenge head on, as we Kellys always do, with toughness, perseverance and faith."
Concerns about the 53-year-old's health were first raised last week when his wife, Jill Kelly, posted a message published on imgur.com. Without going into detail, Jill Kelly noted that the family was going through a "more serious battle under our roof," and asked followers to pray for her husband "for healing."
Later, a youth sports foundation in Sioux Falls, S.D., announced that Kelly would not be able to attend the Hy-Vee/Sanford Legends banquet on June 13 for personal reasons.
Jill Kelly noted the cancellation with a post on her Twitter account on Friday in responding to a person disappointed the quarterback won't be attending the banquet.
"He is disappointed as well," Jill wrote. "But his health must come first! Please pray for him :)"
Jim Kelly has encountered numerous health problems over the past few years, and has had surgery to correct back, neck and hernia problems.
Then, in mid-March, Kelly revealed in an interview with the State Journal-Register of Springfield, Ill., that he recently had surgery to remove a cyst -- which he's described as being "the size of a nickel" -- from his gums and nasal cavity. As part of the operation, doctors had to pull out his front teeth, Kelly said.
Kelly appeared to be having no setbacks in his recovery, after making numerous public appearances over the past month.
Kelly was in good spirits attending rookie quarterback EJ Manuel's first news conference at the Bills' facility on April 26, a day after Buffalo selected the player in the first round of the draft.
Two weeks ago, Kelly watched a Bills practice session from the sideline, after which he chatted up several players.
On May 26, Kelly joined country music artist Tim McGraw on stage and threw footballs into the crowd during a concert outside Buffalo.
Jill Kelly posted photos of her husband with McGraw, as well as her husband attending The Preakness in Baltimore on May 18.
Jim Kelly was upbeat in addressing reporters on Sunday, while attending his charity's annual gala and auction, noting that his 84-year-old father, Joe, was in attendance. He said this year's event was projected to raise close to $5 million. And he noted how this was an opportunity to see many friends and former teammates.
"Jim's a fighter. We think he'll be OK. We're all in his corner," former Bills receiver Andre Reed said. "He's such a resilient guy, and that's been our motto forever, in whatever we did.
The Kelly for Kids Foundation was established in 1987, and has since donated tens of millions of dollars to numerous organizations around the region.
Kelly later founded the Hunter's Hope Foundation in honor of his son, Hunter, who was born in 1997 with Krabbe disease. That's an inherited degenerative disorder of the central and peripheral nervous systems. The disease hinders development of the myelin sheath, a fatty covering that protects the brain's nerve fibers.
Given little more than three years to live, Hunter died at the age of 8 in 2005.