Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

MANILA, Philippines — Officials say a recently dismissed security guard has released his hostages and walked out of a Philippine shopping mall, ending a daylong hostage crisis in an upscale commercial district near the police and military headquarters.

The man, identified by police as Archie Paray, a former guard at the complex, left the V-Mall in suburban San Juan city in metropolitan Manila on Monday evening with his hostages, who were secured by police.

The suspect was allowed to speak to reporters and authorities to outline his grievances against his former superiors, whom he accused of corruption and abuse, before police approached and subdued him.

Police say the man shot a security officer in the morning before rushing to the second floor of the complex, where he held dozens of people, mostly employees, hostage in an office. The number of hostages wasn't immediately clear.

Mayor Francis Zamora of San Juan in the Philippine capital said the gunman, who was armed with a pistol, was a disgruntled former security guard at the shopping complex.

“He felt bad because he was removed as a guard,” Zamora told reporters, adding that the man tried but failed to convince fellow guards to join him.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The suspect was complaining of “unequal treatment,” the police report said.

Download the NBC News app for breaking news and politics

He was apparently dismissed from work after abandoning his job in recent weeks without notifying management, Zamora said. He said the hostages were fine and added that authorities were trying to resolve the situation without further violence.

The suspect used his cellphone to deliver a message to the guards and the media, expressing his anger over a change in his work hours and accusing his superiors of corruption.

In a bid to appease the hostage taker, six officers in charge of overseeing the mall's security apologized to the suspect at an early evening news conference for their “shortcomings” and resigned or offered to quit.

“I’m asking for his forgiveness, and because of this, I’ll resign from my job so this crisis will come to an end,” said Oscar Hernandez, one of the security officers.

Earlier in the day, more than a dozen SWAT commandos were seen entering the mall, their assault rifles ready. Other policemen stood by outside, along with an ambulance.

The shopping complex, popular for its restaurants, shops, bars and a bazaar, lies near an upscale residential enclave, a golf club and the police and military headquarters in the bustling metropolis of more than 12 million people, where law and order have long been a concern.

Three years ago, a gunman stormed a mall-casino complex in Manila, shot TV monitors and set gambling tables on fire, killing 36 people who were mostly suffocated by the thick smoke. The gunman stole casino chips before he fled but was found dead in an apparent suicide in an adjacent hotel at the Resorts World Manila complex.

The attack, which caused guests and shoppers to flee to safety, was claimed by the Islamic State group, but Philippine authorities rejected the claim, saying the attacker was not a Muslim militant but a heavily indebted gambler.