At least three people accused of involvement in last month's deadly Madrid railway bombings blew themselves up Saturday as police tried to arrest them, Spanish authorities said.

A special forces agent was killed and 11 other police officers wounded in the blast, officials told a news conference.

The residential area had been evacuated before police moved in on the apartment building in Leganes, a suburb just south of Madrid.

"The special police agents prepared to storm the building and when they started to execute the plan, the terrorists set off a powerful explosion, blowing themselves up," said Interior Minister Angel Acebes.

"There are three that could have blown themselves up, but the possibility of more is not ruled out," he said.

A Moroccan extremist group with ties to al-Qaeda is under investigation for the March 11 bombings. The attacks killed 191 people and wounded more than 1,800.

Toledo bomb same as Madrid explosives

Meanwhile, the Spanish government confirmed Saturday that a bomb found on a high-speed rail line near the city of Toledo on Friday was the same type as that used in the Madrid attacks.

Rail workers discovered the 12-kilogram bomb in a sports bag on Friday. The Goma 2 Eco dynamite, commonly used in mining in Spain, was on the tracks between Madrid and Seville.

Train service along the line was restored Saturday. The government said the army would guard key parts of the country's rail network.

The dynamite was connected to a detonator with about 130 metres of cable, officials said. Bomb experts were able to defuse the device.

"It's the same type of explosives and the same brand," Acebes told reporters.

He said it's too soon to draw any conclusions about which group may be responsible for planting the bomb found on Friday.