State television and anti-government activists earlier had reported 15 dead. The television said a "terrorist suicide blast" hit the Iman Mosque in central Damascus, and Mohammed al-Buti, imam of the ancient Ummayyad Mosque, was among the dead.
"The death toll from the suicide bombing of the Iman Mosque in Damascus is 42 martyrs and 84 wounded," the health ministry said later in a statement.
While attacks in the capital during Syria's two-year-long rebellion have become almost commonplace, an attack on a mosque was deeply shocking to both sides in the conflict.
Buti, a government-appointed cleric reviled by the Syrian opposition movement, delivered the official weekly on Friday mosque sermons on state television.
In one of his televised speeches, Buti described those fighting to topple President Bashar al-Assad as 'scum'. He also used his position to call on Syrians to join the armed forces and help Assad defeat his rivals in the rebellion.
Rebel spokesman Loay Maqdad said units associated with the opposition's Free Syrian Army were not behind the attack.
"We in the Free Syrian Army do not take any responsibility for this operation. We do not do these types of suicide bombings and we do not target mosques," he told Al Arabiya television.
Video released by Syria's al-Ikhbariya channel showed dozens of limp bodies lying on the bloodied carpet of the mosque, as emergency workers rushed in to give survivors first aid. Mangled limbs lay among the wreckage.
The British-based Syrian Observatory for Human Rights, which has a network of activists across Syria, said earlier that around 15 people died in the blast in central Damascus.
The Observatory said it was unclear if the explosion was caused by a car bomb or a mortar shell. Dozens more were wounded in the attack it said.
The Iman mosque is next door to the offices of Assad's ruling Baath party, as well as other government compounds.
Locals were panicked after the blast and described seeing ambulances rushing to the area while traffic came to a standstill. Residents near the mosque said the strong, acrid smell of gun powder still hung in the air.
"RECEIVING GOD'S WRATH"
Buti, 84, led the funeral prayers for Assad's father, the late President Hafez al-Assad.
The imam's critics saw him as a religious mouthpiece in support of Assad. When the revolt started in March 2011, he quickly threw his support behind the Assad family, which has ruled Syria for more than four decades.
Buti was a Sunni Muslim, the sect which makes up the majority of Syria's population.
Sunnis have led the revolt against Assad, a movement that began as peaceful protests but devolved into bloody civil war that has sparked sectarian bloodshed between Sunnis and Assad's minority Alawite population.
It was unclear who was behind the Damascus blast, although Syria TV immediately accused "terrorists," a term frequently used to described rebels. If opposition fighters were responsible, it would signal the ease with which they are able to strike in the heart of the capital compared to a year ago.
Some opposition activists argued the rebels could not have been behind the attack, and called it a government plot. They said it was unlikely that rebels, many of whom are deeply religious, would target a mosque.
"The regime eliminated Buti," said Leena al-Shami, a Damascus activist speaking on Skype. "One of the last things he said is that Assad is the prince of Muslims and Syrians fight with him, as in jihad (holy war).
"I don't think Buti could have done more, his role was over. Now the regime wanted to make a martyr of him."
Some locals recalled one of Buti's more memorable sermons from early on in the revolt, in which he told President Assad he had a vision that Syria would 'receive God's wrath', but would survive.