A 20-year-old man wielding a knife jumped out and tried to stab Gayoom in the stomach on an atoll of the predominantly Muslim island nation, the Press Trust of India reported.
Mohamed Jaisham, a 15-year-old Boy Scout, wrestled the attacker to the ground, the report said quoting officials.
"The president escaped this serious attack without any harm. However, a Boy Scout was injured in the incident," an official statement issued in Male said.
The extent Jaisham's injuries was not available. The motive for the attack was under investigation.
Gayoom is Asia's longest-serving leader. He has remained in office through a series of yes-or-no referendums, the BBC reported.
The capital was the scene last September of a bomb attack near a mosque blamed on Islamic militants.
International tourism is the mainstay of the nation's economy, but some parts of the Maldives, southwest of Sri Lanka in the Indian Ocean, have seen a rise in Islamist extremism in recent years.