The attack took place during prayers for the Islamic festival of Eid al-Adha.
Goita was taken from the scene, according to the journalist, who said it was not immediately clear whether he had been wounded.
An official at the presidency later said Goita was “safe and sound.”
Goita arrived at the military camp of Kati, outside the capital, “where security has been reinforced,” the official said.
Religious Affairs Minister Mamadou Kone said that a man had “tried to kill the president with a knife” but was apprehended.
Latus Toure, the director of the mosque, said an attacker had lunged at the president but wounded someone else.
The shocking attack follows months of political turmoil in Mali, which is also battling a jihadist insurgency that has claimed thousands of lives and driven hundreds of thousands from their homes.
Goita was sworn into power in June, after leading the country’s second coup in less than a year.
The colonel had already led a putsch last August, when he and other army officers ousted elected president Ibrahim Boubacar Keita after weeks of mass protests over corruption and the long-running jihadist conflict.
The second coup in nine months sparked diplomatic uproar, prompting the African Union and the Economic Community of West African States (ECOWAS) to suspend Mali, calling for the appointment of a civilian prime minister.
– Jihadist insurgency –
France, which has thousands of troops stationed in the war-torn country, also suspended military cooperation with Mali.
The former colonial power followed by announcing that it would wind down its 5,100-strong Barkhane force that has battled jihadists in the Sahel since 2013.
The military junta handed power to a civilian-led transitional government, which promised to restore civilian rule in February 2022.
In June it unveiled its new government, appointing military figures in key roles.
Goita vowed that the government would “uphold all its commitments”, pledging to stage “credible, fair and transparent elections”.
A large majority of the 15-nation UN’s Security Council later called for free and fair elections to go ahead in the country without the participation of its current leaders.
Mali also faces unrest outside the political arena.
It 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.