Three suspected terrorists blew themselves up as police were closing in and another suspect was shot dead by police while he was preparing to detonate his explosives, authorities said.

A police officer was killed and a child was injured, officials said.

Tuesday's suicide blasts revived memories of five near-simultaneous bombings in May 2003 that killed 45 people in Casablanca, an event that brought fear of terrorism into many Moroccan minds for the first time.

Police in the North African kingdom have led an unprecedented crackdown on terror suspects since then — and Tuesday's police raid was triggered by an investigation into a cybercafe bombing last month.

Moroccan authorities responded to the 2003 attacks by arresting thousands of alleged Islamic militants — some accused of working with Al Qaeda and affiliates to plot strikes in Morocco and abroad.

Tuesday's bombings came as Morocco prepares for parliamentary elections in September. The opposition Justice and Development Party, an Islamic group, is expected to win the most votes.

Officials said the raid targeted four suspects with alleged links to the bomber who killed himself in a Casablanca cybercafe on March 11.

"These men had no ties with foreign groups," said Mokhtar Bakali, regional administrator for the Casablanca region. "All of the suspects were members of the March 11 group."

One of the bombers who killed himself, Ayyoub Raydi, was the brother of the cybercafe bomber, Abdelfettah Raydi, an Interior Ministry official said. The official asked that he not be named, citing ministry policy.

The violence started when police, responding to a tip, surrounded a four-story apartment building in the Hay Farah neighborhood of the Fida area of Casablanca where the suspected terrorists were holed up.

After police surrounded the building, one of the suspects fled to the roof, where he blew himself up, said a police official who 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.

A second man appeared to be on the verge of also detonating explosives, fumbling with his clothes, when a police sniper shot him, officials said. The suspect later died of his wounds. He was identified by police as Mohamed Mentala. Mentala was carrying nearly 9 pounds of explosives, the ministry official said.

Mentala and Rachidi had both been sought by police for alleged involvement in the 2003 bombings, the official said. MAP said Rachidi, 37, was part of a terror cell involved in the killing of a Casablanca police official in 2003.

Ayyoub Raydi blew himself up in the afternoon as police were searching the neighborhood for him, officials said. A bloody pair of legs were seen lying in the middle of a road after that blast. Police covered up the legs, shorn off at the knees, with pieces of cardboard. Broken glass and charred debris littered the street.

A police officer was killed and another seriously injured in the explosion, the official said, and a 7-year-old boy was hospitalized with slight injuries.

Police cordoned off the area, erecting metal barriers to keep hundreds of onlookers back.

In the evening, a fourth suspect detonated his explosives in the middle of a boulevard, witnesses said. MAP reported the blast injured eight people — two seriously. It gave no further details.

"We all thought that the guy had gone the other way — and then Kblam! — there was this explosion behind us," said a shopkeeper who gave his name only as Saad. "This is horrible. There's no trust here anymore, because they (the bombers) can get so close to you."

Investigations into the cybercafe bombing led police to a wider suspected plot to attack Casablanca's port as well as police stations and tourist sites in Morocco.

In that blast, Abdelfettah Raydi detonated his charge when the cybercafe's owner caught him surfing jihadist Web sites. He was killed and four others were injured.

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.

Police have so far arrested 31 suspects, who have been questioned by judges in preliminary court hearings. 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.