Latus Toure, the director of the Great Mosque, said an attacker had lunged for the president but wounded someone else.
"The attacker was immediately overpowered by security. Investigations are ongoing," Reuters quoted as the Mali presidency said.
Mali has been struggling to contain an jihadist insurgency that first emerged in the north of the country in 2012, and has since spread to Burkina Faso, Mali and Niger.
Thousands of soldiers and civilians have been killed and hundreds of thousands have fled their homes.
The conflict has also been mirrored by political instability in the capital.
Colonel Goita led a coup last August, ousting elected president Ibrahim Boubacar Keita after weeks of mass protests over corruption and the long-running jihadist conflict.
In May, he ousted a transitional government that had been entrusted with the task of leading the country back to civilian rule in February 2022.
He was then named transitional president, but has pledged to keep to the goal for returning to civilian government.