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

Police in Dallas used a robot with an explosive device to kill a suspect involved in a coordinated ambush against officers.

The suspect was holed up inside the El Centro College parking garage for several hours overnight Thursday before police moved to "blast him out," Mayor Mike Rawlings said Friday morning. The negotiations with the suspect had stalled.

PHOTOS: Dallas Police Officers Killed in Protest Shootout

"We saw no other option but to use our bomb robot and place a device on its extension for it to detonate where the suspect was," Rawlings told reporters. "Other options would have exposed our officers in grave danger."

Series of flashing lights visible inside El Centro where #DallasPoliceShooting suspect may be holed up. @dallasnews pic.twitter.com/nNgvwvhrcf — G.J. McCarthy (@gjmccarthy) July 8, 2016

A senior law enforcement official told NBC News the suspect is believed to be Micah Xavier Johnson, 25, from the Dallas area.

The mayor said the suspect was killed by the device, and disputed earlier reports that he might have shot himself.

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

The ambush occurred during a protest Thursday night over police-involved shootings elsewhere in the country. Five officers were killed and seven others were injured, as well as two civilians.

Investigators believe Johnson was the lone gunman, multiple senior U.S. law enforcement sources told NBC News. Three other people were taken into custody. The investigation into those people remained ongoing Friday.

RELATED: 12 Officers Shot, 5 Killed During Protest

Typically, police forces have bomb squads that employ remote-controlled robots for dismantling explosive devices.

But using robots with explosives or munitions to root out or even kill suspects appears far less routine, experts say.

In Albuquerque, New Mexico, in 2014, a SWAT team used a robot when dealing with an armed suspect who barricaded himself inside of a motel room. The bomb squad's robot deployed chemical munitions, "which led to the subject’s surrender," police said.

Peter W. Singer, a technological warfare expert and author of "Wired For War," told NBC News that using mobile robots — or MARCbots (Multi-Function Agile Remote-Controlled) — to detonate explosives was documented during the early days of the Iraq War — but it's not something he has heard of in domestic policing.

He added that while robots aren't typically designed to be armed — they're used for observation or dismantling purposes — law enforcement could decide to use bomb robots when officers are in immediate danger.

Yes, this is 1st use of robot in this way in policing. Marcbot has been ad hoc used this way by troops in Iraq. https://t.co/FfrsgLS2x1 — Peter W. Singer (@peterwsinger) July 8, 2016

There may be ethical and legal discussions about using a robot to kill the suspect in Dallas, but when it comes down to it, police can argue that they needed to react quickly to use lethal force, police law expert Seth Stoughton told The Atlantic.

"If someone is shooting at the police, the police are, generally speaking, going to be authorized to eliminate that threat by shooting them, or by stabbing them with a knife, or by running them over with a vehicle," Stoughton said. "Once lethal force is justified and appropriate, the method of delivery — I doubt it’s legally relevant."