Rep. Mo Brooks said Wednesday he’s been diagnosed with prostate cancer.

The Alabama Republican made the announcement during a House floor speech.

"God works in mysterious ways. When you are an elected official, missed votes require an explanation," he said. "That is why I disclose this otherwise very personal, very private, and very humbling matter."

Brooks will get surgery on Friday and plans to recover over the holidays. He intends to be back to work in January.

Earlier this year, Brooks lost the Republican primary for the Senate seat once held by Attorney General Jeff Sessions, coming in third to Sen. Luther Strange and Roy Moore.

He said that loss may have saved his life.

"Had I won, I would not have had time for my physical and PSA test," he said. "I would not have had a prostate biopsy. I would not now know about my ‘high risk’ prostate cancer that requires immediate surgery."

The congressman said he learned of his diagnosis on Halloween.

"After my doctor’s diagnosis, I called my wife, Martha, who was back home in Huntsville welcoming trick-or-treaters, and shared the bad news," he said. "That night was one of the loneliest nights apart in our 41-year marriage. I kept thinking about my wonderful family, ‘What do I do next,’ and ‘How do I beat this cancer?’"

He shared that his grandfather was diagnosed late, and died soon afterward. But his father's diagnosis was caught early, and he lived for decades after his own surgery.