LUCKNOW, INDIA -- The top suspect in the ambush killings of eight police officers last week and dozens of other crimes was fatally shot in police custody Friday while allegedly trying to flee, officials said.

Vikas Dubey snatched a revolver from officers after their vehicle overturned on a highway near the northern Indian city of Kanpur and tried to flee, said police officer Mohit Aggarwal. He said Dubey died in an exchange of gunfire.

Dubey, in his 40s, had given himself up in the central town of Ujjain on Thursday after a weeklong search. He was being driven in a police convoy to Kanpur where the eight police officers were killed.

He is believed to have links with state politicians and the police. Two police officers were arrested this week for allegedly tipping him off about a police raid on his home last Friday.

Police in the past four days killed six of Dubey's alleged accomplices in helping him evade arrest, said Avneesh Awasthi, a state government spokesman.

Amarnath Aggarwal, an opposition Congress party leader, accused police of planning the killing of Dubey. "It was committed with the motive that Dubey did not reveal the names of people who provided patronage and protection to him."

Deaths in police custody are not isolated incidents in India.

A report last month by a New Delhi rights group, the National Campaign Against Torture, said at least 1,731 people died in custody during 2019, which means five custodial deaths a day.

In December last year, police shot dead four men suspected of raping and killing a young female veterinarian in southern India after investigators took them to the crime scene. Human rights groups have been calling for investigations into the deaths.

Ghanshyam Upadhayay, a Mumbai-based lawyer, had petitioned India's Supreme Court on Thursday for the killings of Dubey's alleged accomplices to be investigated.

Dubey was killed before the court could rule on his petition.

The New Delhi Television channel reported that police had stopped media cars following the police convoy on the highway half an hour before Dubey was killed. There was no immediate police comment.

Last week, police sought to arrest Dubey and others accused of being in his criminal gang. Police say the suspects blocked the road with excavators and fired at them from rooftops, police said. Five officers were also wounded and the assailants fled before police reinforcements could reach the area.

Uttar Pradesh, with a population of 230 million, is one of the most impoverished states in India. It's also considered one of the most lawless with high incidents of armed robberies, kidnappings for ransom and crimes against women, according to the National Crime Record Bureau.

Dubey was allegedly involved in 60 cases of killings, robberies and kidnappings. Among them was the killing of local Bharatiya Janata Party leader Santosh Shukla in a police station in 2001. Two police also died in the attack.

Associated Press writer Sheikh Saaliq in New Delhi contributed to this report.