The man behind London's Westminster Bridge terror attack in 2017 had a grudge against President Donald Trump and British Prime Minister Theresa May, a British inquest into the victims' deaths heard Wednesday.

Khalid Masood, who was ultimately gunned down by authorities after he killed five people by driving an SUV into pedestrians on the bridge and stabbing an unarmed constable on the grounds of Parliament, complained about the "racism and rudeness" of Trump and called May a "liar" and "sick," his children told authorities.

Attacker Khalid Masood is treated by emergency services outside the Houses of Parliament in London on March 22, 2017. Stefan Rousseau / PA via AP file

Masood's planning for the March 22 attack began when he researched off-road SUVs and reserved a Hyundai Tucson rental for the days leading up to the violence, the jury conducting the inquiry was told. On March 9 he purchased two Sabatier kitchen knives at a store near his U.K. home.

He looked into using gasoline as part of a car-bomb attack, researched improvised explosive devices, and searched online for the prime minister's activities that day, the jury heard. He also researched speed and crash tests for vehicles.

Masood visited his mother in Wales days before the attack, telling her, "They'll say I'm a terrorist. I'm not." He had tried to convert former colleagues to Islam, applying heavy pressure, authorities said.

By the time the 52-year-old English teacher made the decision in March to plow into pedestrians before heading on foot to the Houses of Parliament, he was at the bottom of a downwared spiral that included debt, unemployment and estrangement from his wife, the panel was told.

In the days before the violence, he stayed at hotels, overstayed the rental period on the SUV and had everything he owned with him. Masood told family—he had four children, his wife, and two ex-wives—he was going to Morocco for a business opportunity, the jury learned.

On the day of the bloodshed, he sent a religious text message with an attached document titled, "Jihad in the Quran and Sunnah," to a random group of contacts, alarming some, authorities said.

"I need to speak with you urgently I called u earlier today," one recipient texted back.

Floral tributes to the victims of the Westminster attack are placed outside the Palace of Westminster, London, Monday March 27, 2017. Attacker Khalid Masood is believed to have used the messaging service WhatsApp before running down pedestrians on Westminster Bridge and storming a gate outside Parliament armed with two knives, Wednesday. Four died in the rampage, including a police officer. (AP Photo/Matt Dunham) Matt Dunham / AP

The inquiry, called an inquest in Great Britain, was expected to last for weeks after beginning Sept. 10. The inquest, heard before a jury, learned about Masood's alleged criminal and violent past.

Born Adrian Elms in Kent, England, he was arrested for shoplifting at 14 and for carrying a weapon at 22. He spent a year in jail after a pub brawl at the age of 35. He converted to Islam in jail, the panel learned.

His mother, Janet Ajao, described Masood as angry and said he would go looking for fights in bars and clubs.

"She said she was worried he would kill someone," said Jonathan Hough, an attorney for the coroner.

An ex-girlfriend said Masood was a fraudster who carried a knife, used steroids and introduced her to cocaine. He once grabbed her neck and tried to strangle her, the jury was told.

Masood threatened to rape her mother if she stood by her statements to authorities, the jury was told.

"Adrian was vile," the unnamed woman said in a statement read in court. "He was controlling, violent, obsessive, intelligent and narcissistic. I am amazed he was religious. I honestly believe this was a front, an excuse to hurt people. He will have loved the attention and fear that he caused."

Despite Masood's despair, the attacker found a glimmer of hope in his life, attributing an acquittal in a knife assault and his daughter's survival after being struck by a vehicle to acts of God, the inquest was told.

The stabbing took place in May 2003 when Masood allegedly plunged a knife through his victim's nose, the palate of his mouth, his tongue and into his jaw bone with such force the last inch broke off, the panel heard.

Masood told a colleague he had been dealing drugs when he pulled a knife on a man, the jury was told. He said he had prayed before his court appearance and was found not guilty of attempted murder.

A woman lies injured after a shooting incident on Westminster Bridge in London on March 22, 2017. Toby Melville / Reuters file

Investigators believe that a trigger for Masood was his failed attempt in 2016 to return to Saudi Arabia with his family. He described the country as a "utopia" with "no discrimination," the jury heard.

Despite an undergraduate degree in economics and experience teaching English, the Saudis requested his criminal history and subsequently rejected his application to return. What's more, a March 11 Skype interview for a job in the kingdom did not result in an offer.

This made him desperate, the inquest was told.

"This is a potentially significant event," Hough, the coroner's attorney, told the jury. "It was clear he was struggling with money and was in debt at the time of his death."

Masood would often speak with his two youngest children via video calls, and they later told police about them. Scotland Yard counter-terrorism detective Dan Brown said, "They told him that he thought he was going to die fighting for God."