A statement released by Geingob’s office did not give further details about his condition but said the president would continue to carry out his duties.
The southern African nation is due to hold presidential and parliamentary elections at the end of 2024.
Geingob told the public in 2014 when he was prime minister that he had survived prostate cancer. He became president the following year.
"As part of regular annual medical examinations, the Presidency informed the Namibian public that the head of state was due for a colonoscopy and a gastroscopy on 8 January 2024, which were followed up with a biopsy, of which the results revealed cancerous cells," the presidency statement said.
"On the advice of the medical team, President Geingob will undertake appropriate medical treatment to deal with the cancerous cells."