Doctors said the Arizona senator has been diagnosed with glioblastoma, an aggressive cancer.
The 80-year-old senator and his family are reviewing further treatment, including a combination of chemotherapy and radiation.
The senator has been recovering at his Arizona home after doctors at the Mayo Clinic removed a blood clot above his left eye.
The doctors said Mr McCain is recovering from his surgery amazingly well and his underlying health is excellent.
Mr McCain was the Republican Party’s presidential nominee in 2008.
He was a navy pilot, and was shot down over Vietnam and held as a prisoner for more than five years.
His office said: “On Friday, July 14, Sen. John McCain underwent a procedure to remove a blood clot from above his left eye at Mayo Clinic Hospital in Phoenix.
“Subsequent tissue pathology revealed that a primary brain tumour known as a glioblastoma was associated with the blood clot.”
Mr McCain’s absence from Washington had forced Majority Leader Mitch McConnell to delay action on health care legislation.
Mr McConnell said: “John McCain is a hero to our conference and a hero to our country. He has never shied from a fight and I know that he will face this challenge with the same extraordinary courage that has characterised his life.
The entire Senate family’s prayers are with John, Cindy and his family, his staff, and the people of Arizona he represents so well.”
Mr McCain and his running mate Sarah Palin lost to Barack Obama in 2008.
Mr Obama tweeted: “John McCain is an American hero & one of the bravest fighters I’ve ever known. Cancer doesn’t know what it’s up against. Give it hell, John.”