TORONTO — A tip from the FBI triggered what Canadian police on Thursday called a “race against time” as police scrambled to identify and locate a balaclava-wearing would-be suicide bomber they feared was on the verge of committing a terror attack in Canada.

Aaron Driver, a Canadian man previously banned from associating with Islamic State extremists, prepared a martyrdom video and was about to commit a terrorist attack but was killed Wednesday after he detonated his explosive device in a taxi and was shot at by officers who say they thwarted the plot. Police say they were tipped off by the American authorities, who provided a screenshot of the masked suspect threatening a terror attack early Wednesday, police said.

The suspect planned to carry out a suicide bombing in a public area in an urban center during rush hour, Royal Canadian Mounted Police Deputy Commander Mike Cabana said. He identified the suspect as Driver, 24, originally from Winnipeg, Manitoba.

RCMP Commander Jennifer Strachan said Driver was intercepted by police as he entered a taxi with a backpack and said Driver detonated an explosive device, injuring himself and the taxi driver, before police shot at him. It was unclear whether Driver died as a result of the shrapnel or a police bullet.

After being tipped off by the FBI, Canadian police worked furiously to find out who it was. Police said Driver was quickly identified as the person in the so-called martyrdom video and that he planned an attack within 72 hours.

“It was a race against time,” Cabana said.

In the video, aired during a news conference in Ottawa, a masked Driver is seen railing against Western “enemies of Islam” and warning that the only solution would be the “spilling of your blood.” He pledges allegiance to Abu Bakr al-Baghdadi, the Islamic State leader, and threatens an attack against Canada.

Driver had been under the spotlight for at least a year, as authorities believed he was a threat because he could help terror groups. He gave a media interview in which he expressed support for prior terror attacks in Canada and expressed interest in traveling to join the Islamic State. But Driver, who was living with his sister, was not under surveillance at the time.

The police operation involving Driver took place Wednesday night in the southern Ontario town of Strathroy, 140 miles (225 kilometers) southwest of Toronto.

“If he had gotten out of that residence before we got there, the scenario would have ended a lot differently. I’m positive of that,” Strachan said.

Transit agencies in Toronto, Canada’s largest city, were warned of a security threat before police confronted the suspect. Brad Ross, spokesman for the Toronto Transit Commission, said the agency was made aware of a terror threat investigation early the previous day, but noted that it had no specifics attached.

He said that as a precaution, a “vigilance notice” was issued to all staff, encouraging them to speak up if they saw something of concern. Regional transit lines were also advised of a security threat.

“This case is an example of the strong cross-border law enforcement cooperation that exists between Canada and the United States. Our partnership reflects our joint commitment to protecting the safety of our citizens,” US Ambassador to Canada Bruce Heyman said in a statement.

Driver was under a court order from earlier this year to not associate with any terrorist organization, including the Islamic State group. In February, Driver’s lawyer and the prosecutor agreed to a peace bond stating there are “reasonable grounds to fear that he may participate, contribute directly or indirectly in the activity of a terrorist group.”

Driver was first picked up in Winnipeg in June 2015.

Amarnath Amarasingam, a post-doctoral fellow at Dalhousie University who studies radicalization and terrorism, maintained in 2015 that Driver had posted for several months on social media about disliking Canada and about a desire to move overseas.

Canadian police applied for the peace bond, which can impose limits on a person’s activities, alleging in provincial court documents that investigators believed Driver might help with terrorist group activities.

When Driver was released later that month, he was ordered to wear a GPS tracking device and banned from going on the internet or having any communication with the Islamic State group, including wearing or carrying anything with an IS logo.

His bail conditions drew criticism from the Manitoba Association of Rights and Liberties. Later, the government announced that some of his strict bail conditions had been lifted and that he would not be going to trial.

Driver was allowed to remove his monitoring bracelet but continued to be prohibited from using a computer or cellphone — rules that were to be in place until the end of August.

Canadian Public Safety Minister Ralph Goodale said he had spoken to Prime Minister Justin Trudeau about the police operation Wednesday night “to confirm that public safety has been and continues to be properly protected.”

He said the RCMP, the Canadian Security Intelligence Service and other police and security agencies were involved in the operation. He also said the national terrorism threat level for Canada remains at “medium,” where it has stood since the fall of 2014.