The man, seen waving around a sharp weapon, studied at the prestigious IIT-Bombay

Lucknow: An IIT graduate attacked two policemen with a sharp weapon outside the Gorakhnath temple in Uttar Pradesh on Sunday evening and tried to enter the temple while shouting religious slogans, before he was overpowered by a crowd and arrested. The incident will be treated as an act of terror, says the UP police.

In dramatic mobile phone videos, Ahmed Murtaza Abbasi, 29, is seen waving what appears to be a machete outside the Gorakhnath temple in Gorakhpur, where Uttar Pradesh Chief Minister Yogi Adityanath is head priest. Murtaza repeatedly lunges at the policemen and shopkeepers who try to catch him.

A small crowd, which included security guards, threw rocks at Murtaza, who hit back but was finally pinned to the ground. The incident took place at around 7 pm on Sunday.

Murtaza graduated from the prestigious IIT (Indian Institute of Technology)-Bombay in 2015, said the police. A laptop, a phone and a ticket were found on him.

It is an act of terror, the police said, adding that investigations would focus on the possibility of a larger conspiracy.

"ltems recovered from the person makes it seems a big conspiracy was in play and we cannot deny that this could have been a terror attack," said Prashant Kumar, Additional Director General, Law and Order.

"Our recoveries are quite sensational and we will share these with you at a later stage. Currently our investigation is at a preliminary stage. Two cases have been registered and the local police are investigating right now but other directions will be passed soon," Mr Kumar said.

Murtaza and the two policemen he attacked are all in hospital. Yogi Adityanath, who travelled to Gorakhnath this evening, met with the injured policemen and visited the site of the incident.

"If this person had entered the temple, pilgrims could have been harmed. Those guarding the temple showed tremendous restraint and arrested this person," said Mr Kumar.

Murtaza has been charged by the UP police with attempt to murder and promoting enmity on the grounds of religion. There is a possibility that more severe charges will be added later.

After graduating, Murtaza had started working with a private company in Mumbai but two years ago, his family brought him back to their hometown Gorakhpur.

His father claims he had suffered from depression since college and was suicidal.

"He used to be constantly ill. He used to take unscheduled leaves at work. When I retired, I brought him back to Gorakhpur because he used to be mentally depressed," Munir Murtaza told reporters.

Gorakhnath is one of the most high profile temples of UP because of its connection with the Chief Minister. Yogi Adityanath has also represented Gorakhpur in parliament and recently won his first state election from the Gorakhpur Urban constituency.

The incident has jolted the administration, especially as it took place in the Chief Minister's home base.

How Murtaza managed to take the weapon so close to the well-guarded temple is among the aspects being investigated.