Toulouse, France (CNN) -- The French police siege to capture a suspected al Qaeda-trained militant came to a bloody end Thursday morning when commandos shot Mohammed Merah in the head as he fired wildly back at them, authorities said.
Merah emerged from a bathroom in his apartment and fired more than 30 shots at police as they burst in to end a standoff that had lasted more than 31 hours, Paris prosecutor Francois Molins said.
He jumped out a window onto a balcony, still shooting, and was found dead on the ground, officials said.
Two police officers were injured in the raid, Interior Minister Claude Gueant said.
Merah had only two bullets left in his gun when he was killed, Molins said.
Merah, 23, was wanted in the killings of three French paratroopers, a rabbi and three children ages 4, 5, and 7. The shootings began March 11 and ended Monday with the slaying of the rabbi and the children at a Jewish school in Toulouse.
Authorities said the young man cited a variety of reasons for the killings, including France's ban on the wearing of Islamic veils, the missions of its troops abroad and the oppression of Palestinians.
Police found video recordings of the attacks, ammunition and ingredients for explosives after he was killed, Molins said.
In the video of the first shooting of a French soldier in Toulouse, Merah told the soldier, "You kill my brothers, I kill you," Molins told reporters. Another video shows Merah gunning down two more French soldiers in Montauban. He is heard saying "Allahu Akbar," or God is great, Molins said.
Merah claimed to have posted the videos online, but police do not know when, where or how, Molins added.
Merah was wearing a bulletproof vest when police raided his apartment, the prosecutor said.
He originally said he would surrender to police, Gueant said, but later vowed that he would resist and kill anyone who tried to take him into custody.
Gueant had said earlier police wanted to capture him alive, saying the priority was "to hand him over to the authorities."
Merah said he wanted to "die with weapons in his hands," Interior Ministry spokesman Pierre-Henry Brandet said overnight.
After Merah's death, French President Nicolas Sarkozy said everything had been done to bring him to justice alive.
But, he said, security forces could not be exposed to more danger as they sought to arrest him, since enough lives had already been lost.
Sarkozy's political rival, Socialist presidential candidate Francois Hollande, congratulated police and said France had always shown that it "knows how to stand up against its worst enemies without losing any of its values."
Campaigning for the French presidential elections, put on hold after the Toulouse school attack, has now resumed, with Sarkozy holding a rally in Strasbourg Thursday afternoon. The first round of voting is due next month.
Sarkozy told supporters that his thoughts were with the victims and their families.
The shootings were not the crime of a madman but of "a monster and a fanatic," he said, and his crimes are "inexplicable and inexcusable."
France is not racist or anti-Semitic, Sarkozy added, and the tragic events of the past few days have shown that the nation is stronger when it is united and lives by its values.
Police had surrounded Merah's house at 3:30 a.m. Wednesday, having tracked him down through computer sleuthing and clues linked to his motorcycle, authorities said.
As police first attempted to seize him early Wednesday morning, Merah shot and wounded two officers, said Molins, the prosecutor.
The prosecutor said Merah had trained with al Qaeda in Pakistan's Waziristan region, bordering Afghanistan, and also spent time in Afghanistan.
He was sent back to France after Afghan police picked him up at a traffic stop and alerted international forces to his presence, Molins said.
Merah's activities led to his inclusion on the U.S. no-fly list, a U.S. intelligence official confirmed Thursday. Merah had been on the list for some time, one reason being that he had attended an al Qaeda training camp, the official said.
Christian Etelin, a lawyer who represented Merah in an earlier incident involving a traffic accident, also said Merah went to Afghanistan two years ago.
After the suspect's death, Etelin said that Merah was psychologically damaged.
"He was completely cut off from reality," Etelin said on CNN affiliate BFM-TV.
Ebba Kalondo, the senior news editor of the television network France 24, told CNN's "Erin Burnett OutFront" earlier that the suspect called her about two hours before police surrounded his home and laid out details of the killings that only police would have known -- "very, very specific information" such as the number of shots fired and the shell casings left behind.
"He seemed to be very aware that a massive manhunt was under way for him," Kalondo said. "He said he wasn't scared, and that neither capture nor death scared him at all."
Merah had been under surveillance by French intelligence for years, Interior Minister Gueant said.
He had "already committed certain infractions, some with violence," Gueant said.
Merah was sentenced 15 times by a Toulouse juvenile court when he was a minor, Molins said.
The French defense ministry said Merah had twice tried to join the French military. His first attempt was in the northern city of Lille, where he was refused because of prior convictions, and his second, in July 2010, was in Toulouse, where he sought to join the Foreign Legion but left during the first round of tests.
Merah was born in Toulouse, said Elisabeth Allanic, a magistrate at the Paris prosecutors office. Gueant said he was of Algerian origin.
Gueant said Merah "wanted to avenge Palestinian children and take revenge on the French army because of its foreign interventions."
France has about 4,000 troops supporting the NATO mission in Afghanistan. The government has said it will pull them out by 2013.
Merah also was opposed to France's recent move to ban women from wearing a full veil, Molins said.
Palestinian Prime Minister Salam Fayyad strongly rejected using his people as a justification for the French killings, calling the string of shootings a "cowardly terrorist attack."
Merah belonged to a group called Forsane Alizza, or Knights of Glory, Gueant said. The French government banned the group in January for trying to recruit people to fight in Afghanistan.
The group issued a "chilling warning" on its Facebook page before it was banned this year, calling on supporters to attack Americans, Jews and French soldiers, terror expert Sajjan Gohel said.
Police tracked Merah down via his brother's computer IP address, which was apparently used to respond to an ad posted by the first victim, Gueant said.
In that first shooting, Imad Ibn Ziaten, a paratrooper of North African origin, arranged to meet a man in Toulouse who wanted to buy a scooter Ziaten had advertised online, the interior minister said. The victim said in the ad that he was in the military.
A message sent from the suspect's brother's IP address was used to set up the March 11 appointment, at which the paratrooper was killed, Gueant said.
Four days later, two other soldiers were shot dead and another injured by a black-clad man wearing a motorcycle helmet in a shopping center in the city of Montauban, about 50 kilometers (30 miles) from Toulouse.
In the attack at the private Jewish school Ozar Hatorah on Monday, a man wearing a motorcycle helmet and driving a motor scooter pulled up and shot a teacher and three children -- two of them the teacher's young sons -- in the head.
The other victim, the daughter of the school's director, was killed in front of her father.
Police, who said the same guns were used in all three attacks, launched an intense manhunt and late Tuesday night zeroed in on the apartment, about 3 kilometers (1.8 miles) from the Jewish school.
CNN's Pierre Meilhan, Carol Cratty, Dan Rivers, Stephanie Halasz, Dheepthi Namasivayam, Anna Pritchard and Kareem Khadder contributed to this report.