A third explosion rocked a boulevard in the Hay Farah neighborhood of Casablanca as police searched buildings and rooftops for accomplices. Ambulances raced in, but it was not immediately clear whether there were casualties.
The explosions, weeks after the bombing of a Casablanca Internet cafe, promised to further rattle the North African kingdom whose first high-profile brush with Islamic terrorism came in five suicide bombings in the city in May 2003.
Moroccan authorities responded to those attacks, which left 45 people dead, with the arrest of thousands of alleged Islamic militants — some accused of working with al Qaeda to plot strikes in Morocco and abroad.
Parliamentary elections are scheduled in September. The opposition Justice and Development Party, an Islamic group, is expected to win the most votes.
Tuesday's violence started with a police raid on an apartment where the suspected terrorists were holed up in the working-class Hay Farah neighborhood.
When officers burst in, one of them fled to the roof, where he blew himself up, said a police official on the scene. The official refused to give his name, saying he was not authorized to do so. Morocco's official MAP news agency identified the bomber as Mohamed Rachidi.
The official confirmed that a police officer was killed and a 7-year-old child was injured.
A second man was on the verge of detonating nearly nine pounds of explosives he was carrying when police shot him, officials said. He later died of his wounds. He was identified by police as Mohamed Mentala.
Mentala and Rachidi had both been sought by police for alleged involvement in the 2003 suicide bombings in Casablanca, said an Interior Ministry official who also asked not to be named, citing ministry policy.
The third suspect fled, then blew himself up hours later as police were searching for him, according to another officer at the scene, who also refused to give his name. The officer said police were also hunting for a fourth suspect, who was believed to be hiding nearby.
MAP said the blast seriously injured a police officer and slightly injured another. It said the bomber had not yet been identified.
The suspects were all allegedly linked to the March 11 bombing of an Internet cafe in Casablanca, an attack that killed the bomber, Abdelfettah Raydi, and four others.
Authorities say the subsequent investigation uncovered a larger plot that involved at least 30 people. The group had amassed dozens of pounds of homemade explosives in a Casablanca apartment and had plans to attack the city's port and police stations, as well as tourist sites across Morocco.
Police have so far arrested 31 suspects. Raydi and many other suspects were among some 2,000 arrested after the 2003 bombings, but were later released from prison under a royal pardon.
Moroccan authorities have said they do not believe Raydi's group had links to international terrorist networks.