President Ali Abdullah Saleh, who has faced nationwide protests against his rule for the past four months, was "lightly wounded in the back of his head," a leader of the ruling General People's Congress (GPC) party told AFP.
His regime blamed the attack on powerful dissident tribesman Sheikh Sadiq al-Ahmar, whose fighters have been battling government forces in the Yemeni capital since a truce crumbled on Tuesday.
"The Ahmar (tribe) have crossed all red lines," GPC spokesman Tariq al-Shami said.
In an audio statement broadcast late Friday on state television, Saleh who was being treated at the defence ministry hospital in Sanaa said, "I am well, in good health," and added that the bombardment had killed seven people.
Saleh, who has been in power in Sanaa since 1978, hit out at "the sons of Al-Ahmar," a reference to Sheikh Sadiq and his brothers, and called on "the security forces to purge state institutions of these gangs."
The attack reportedly killed three officers of the elite Republican Guard.
Prime Minister Ali Mohammed Mujawar also suffered burns to his face, while a source close to the presidency said deputy premier General Rashad al-Alimi was "critically wounded."
Officials said the wounded included parliament chief Yahya al-Raie, Saleh's private secretary Abdo Burji, Abdulaziz Abdulghani, head of Yemen's consultative council, GPC MP Yasser al-Awadi, Sanaa Governor Noman Duweik and the mosque's imam.
Washington condemned the violence . "The United States condemns in the strongest terms the senseless acts of violence today in Yemen, including the attack against the presidential palace compound in Sanaa as well as other attacks in Sanaa and throughout the country," the White House said.
"We call on all sides to cease hostilities immediately and to pursue an orderly and peaceful process of transferring political power as called for in the GCC-brokered agreement," it said, referring to the regional Gulf Cooperation Council bloc.
After Saleh last month refused to sign a GGC plan for him to step down in return for immunity, opposition tribesmen seized public buildings in Sanaa, sparking clashes with troops loyal to the president.
In the wake of the latest escalation, the European Union activated a mechanism to evacuate its citizens, foreign affairs chief Catherine Ashton said. Germany on Saturday ordered the closure of its embassy and rapid repatriation of its staff.
Friday's mosque attack came as fighting that has killed scores of people in north Sanaa spread to the capital's south.
Later on Friday, Yemeni troops, who have deployed heavy weaponry in their battle against the tribesmen, shelled the home of Sheikh Hamid, a brother of Sheikh Sadiq.
Shelling in Hada neighbourhood also targeted the homes of their two other brothers, Hemyar and Mizhij, and that of dissident General Ali Mohsen al-Ahmar.
Sheikh Hamid accused Saleh of orchestrating the mosque attack as an "excuse to shell and destroy my home and the homes of my brothers, Hemyar and Mizhij, and that of Ali Mohsen al-Ahmar in an attempt to drag Yemen into civil war."
Saleh last month ordered the arrest of the 10 Ahmar brothers, all sons of Sheikh Abdullah al-Ahmar who was the president's main ally until his death.
Artillery and heavy machine-gun fire rocked the Al-Hasaba neighbourhood of northern Sanaa where Sheikh Sadiq has his base, witnesses said. They said the headquarters of national airline Yemenia was burnt down on Friday.
More than 60 people have now been confirmed killed in the fighting in Sanaa since a fragile four-day truce collapsed between Ahmar's tribesmen and troops loyal to Saleh.
Hundreds of anti-Saleh demonstrators on Friday gathered at Change Square for a day of solidarity with Taez, south of Sanaa, where security forces this week smashed a months-long sit-in protest at a cost of more than 50 lives.
In Taez, clashes on Friday killed four soldiers and two protesters, a security official told AFP, adding that some of the demonstrators were armed. Nationwide, more than 200 demonstrators have been killed since the protests erupted, according to an AFP tally based on reports from medics and rights activists.