BEIRUT—Powerful bombs exploded outside two Sunni mosques in northern Lebanon as worshipers were leaving Friday prayers, killing at least 42 people and wounding more than 500 in the deadliest attack since the end of Lebanon's civil war.

Black smoke billowed above the port city of Tripoli, where the blasts occurred about 1 p.m. Worshipers and bystanders—some soaked in blood—were seen running frantically in streets lined with charred vehicles, their frames gnarled from the blasts, in images broadcast by local television.

The targeting of the Taqwa and Salam mosques is set to worsen an already bitter divide between the country's equally sizable Shiite and Sunni populations, and is likely to lead to reprisals. The targeted mosques are home to some of the most scathing critics of Hezbollah, the local Shiite political and militant group.

"We are at the beginning of the storm," said Ashraf Rifi, the former chief of Lebanon's police forces who lives near the blasts, in an interview on a local television station.

Friday's attacks come after a car bomb last week ripped through Dahiyeh, a Beirut suburb that is home to some of Hezbollah's biggest interests. That bomb killed at least 22 civilians and wounded more than 330. The attacks come hours after an Israeli airstrike hit a town outside of Beirut, in retaliation for four rockets fired into northern Israel from southern Lebanon Thursday by an al Qaeda spinoff.

In Tripoli, residents described scenes of carnage and fear.

"I heard the blast and I just ran. Stuff was flying everywhere," said one man who was sitting at a cafe across the street from one of the blasts.

The man, who declined to be named, said he took cover in a shop, its windows blown out from the blast. People were walking about in complete shock, he said. "My friend lost his arm."

The casualty toll is the worst since Lebanon's 15-year civil war ended in 1990. But some commentators said the attacks weren't a prelude to all-out war, but more likely the start of a protracted period of bubbling sectarian violence of the kind seen from 2006 to 2008.

"Hezbollah doesn't want to be part of any civil war as it will take them away from their main goal—fighting against Israel and fighting in Syria," said Mohammed Obeid, the former director general of Lebanon's Ministry of Information, who is close to Hezbollah's leadership. "But what happened today in Tripoli made everyone feel that not only the Shiites are being targeted but all of Lebanon is now vulnerable."

Until now, Lebanon has largely avoided violence between its various sects. But if a series of revenge attacks does materialize, the country's weak security forces will find it hard to keep the situation from spiraling out of control, especially as civilians take up arms to patrol their neighborhoods themselves.

As the military arrived at the blast site Friday, they were shot at by local residents, according to a local TV report. Many of the country's Sunnis believe Hezbollah controls the military.

Salem al Rafei, a prominent cleric targeted in the attack, had long encouraged the formation of such militias, which he called Sunni defense councils. After last week's bombing, pro-Hezbollah neighborhood watch groups formed to create checkpoints throughout Dahiyeh.

Mr. al Rafei has labeled Hezbollah and its followers heretics, while also calling for jihad against the Syrian government. The influential cleric has also encouraged his followers to fight in that country's civil war against President Bashar al-Assad and his Hezbollah allies.

Mr. al Rafei is a Salafist cleric, a hard-core Sunni Islamist movement that has gained traction in Lebanon since the start of Syria's civil war, which has inflamed sectarian tensions across the region.

Salafists view Shiites as heretics and Hezbollah has often claimed it is fighting in Syria against "takfiris," extremist Salafi elements that have no tolerance for other faiths.

"The escalation of recent weeks signal a new phase. Lebanon is now fully part of the geography of the Syrian conflict. More such incidents are, sadly, likely," said Emile Hokayem, a senior Fellow for Regional Security at the International Institute for Strategic Studies.

Tripoli has been a flash point for tensions between Sunnis and Alawites—an offshoot of Shiite Islam and the religion of the Syrian president.

Deadly urban warfare between Alawites and Sunnis in Tripoli has gone on throughout the past year as neighbors fire on each other, violence that security forces have been unable to curb. One telling photo of those clashes from earlier this year showed a militant stealing a gun from a Lebanese soldier, who helplessly ran after the thief.

Hezbollah put out a statement expressing "pain" and "solidarity" with the Tripoli victims. The group blamed unspecified international forces for perpetrating the attack—a nod to the involvement of foreign governments a generation ago in Lebanon's civil war, which helped orchestrate car bombs and propped up local militias.

"These bombs are part of a criminal scheme to sow the seeds of discord among the Lebanese to drag them into internal fighting…This would serve the sly international plans for the region who want to break it up and drown it in the seas of blood and fire," the Hezbollah statement said.

The caretaker Prime Minister Najib Mikati, a Tripoli native, condemned the bombing. "Criminal hands targeted Tripoli yet again today in a clear message to sow discord," he said.

Mr. Mikati, who has a home near the blast sites, cut short a trip abroad to return to Lebanon, state media said.

The European Union's foreign policy chief, Catherine Ashton, also issued a statement condemning the attacks and called on "all sides to exercise restraint in order to facilitate the course of investigations and justice."