Paris ( CNN ) -- A hostage-taking incident in Toulouse , France , ended with shots fired , the gunman wounded and the last two remaining hostages freed , police union spokesman Christophe Crepin said Wednesday . The gunman , who said he was with al Qaeda , took four people hostage at a bank five hours earlier , police said . He released one of them , a woman , after about three hours , Crepin said , and a second hostage was released about an hour after that . The incident ended after the man emerged from the bank with a hostage and attempted to shoot police officers , Crepin said . A hostage negotiator had earlier spoken to the gunman by phone , Crepin said . Described as a man in his 20s or 30s from France 's Haute-Garonne region , the gunman was `` very , very agitated '' during the talks , he said . Authorities have not officially identified the hostage-taker , security police spokesman Frederic Tamisier said . He said the two remaining hostages were freed after the shootout , in which the gunman was `` not badly '' injured . Toulouse prosecutor Michel Valet said the gunman fired two shots as the action began . He said the four hostages are all safe and sound . The hostage-taker is in a Toulouse hospital , he said , but not in a critical condition . He has two injuries -- one in the left hand and the other in the right thigh -- which , Valet said , indicate that police sought to neutralize him to protect the hostages , rather than trying to kill him . The hostage-taker was armed with a pistol that usually fires rubber bullets but can be converted to fire lethal rounds , Valet said . No more shots were fired from either side once the hostages were secured , he added . `` We can consider that things have ended rather well , no police officers injured , that the four hostages are not injured either , and that the hostage-taker , while he may be injured , his life is apparently not in danger , '' he said . Valet said the man suffers from `` psychological troubles , and his acts are linked to these claims which are badly defined , badly expressed . At this hour , it is difficult to know exactly what is driving his behavior , ( which is ) everything but rational . '' President Francois Hollande hailed the professionalism shown by the police in bringing the situation to a close . `` I rejoice that all the hostages were liberated , safe and sound , and that the hostage-taker was captured , '' he said in a written statement . The incident happened several hundred yards from the scene of a standoff between police and a gunman earlier this year that ended with the gunman dead . In March , police cornered Mohammed Merah , who was wanted in the killing of seven people . He was killed March 22 by police after the 32-hour siege of a Toulouse apartment . Crepin said Wednesday 's hostage-taking was an armed robbery that went wrong . The hostages were the director of the bank and three employees , he said . Valet 's office was in charge of the situation , he said . Photographer Jenet Gautier , who lives near the bank , said the neighborhood was calm during the incident and the situation was not comparable to the Merah siege . A high school in the area was evacuated , staff there said . Investigations shed new light on Toulouse terrorist shootings . A local real estate agent told CNN that police told her to stay inside and keep her doors locked . Marie Cluzaud , 28 , said she was scared but did n't hear any noise connected to the hostage-taking . Streets were blocked off , she said . In the March standoff , Merah was wanted for the killings of three French paratroopers , a rabbi and three Jewish children ages 4 , 5 , and 7 . Two other people were seriously wounded in shootings blamed on him . CNN 's Stephanie Halasz , Saskya Vandoorne , Dheepthi Namasivayam , Ines de la Cuetara and Alex Felton contributed to this report .
NEW : President Hollande hails the police operation and safe release of hostages . The hostage-taker was shot in the hand and thigh , the Toulouse prosecutor says . The man has `` psychological troubles '' and his motivation is not clear , he says . The gunman claims to be linked to al Qaeda , police say .