Police say they are treating an attempted nail bomb attack on a mosque as a terrorist incident. West Midlands police said its counter terrorism unit was leading the investigation into the second bomb attack against a mosque in the West Midlands in three weeks.

They said a "large explosion" was heard near the Kanzul Iman Mosque mosque in Binfield Street, Tipton, where residents reported finding nails and debris. No injuries were reported. Adrian Bailey, Labour MP for West Bromwich West, said it could have been a revenge attack for the murder of soldier Lee Rigby, whose funeral was held .

First reports suggested a device had been thrown at the mosque just after 1pm and may have exploded in the car park.

In winter and autumn, the mosque would have been full for the main prayers of the week at that time. But they were held about an hour earlier.

Bailey said: "Given that it is Drummer Lee Rigby's funeral today, and previous attacks at mosques across the country, it certainly seems that this may have been connected in some way.

"A nail bomb had exploded shortly after 1pm, when the mosque is usually at full capacity … The devastation and potential loss of life that may have been suffered was avoided. Police are investigating how the device ended up in the car park of the mosque, but it seems that it may have been placed there by somebody using a disused railway tracks that overlook the mosque.

"At the early stages, everything points towards this being a premeditated attack."

Detectives believe those behind the attack intended to cause serious injury and that the suspected device had enough explosive power to achieve this.

A West Midlands police spokesperson explained why it was being treated as a terrorist incident: "The reports of explosions and the nails found appear to indicate intent to cause serious inquiry or damage."

The immediate suspects will be those linked to a far-right extremist ideology, which in recent years has increasingly targeted Muslims, at least in its propaganda.

Police added they had no record of previous incidents at the mosque, but some locals said they believed "threats" had been received.

Umar Zeeshan, 43, who was in the mosque, said: "It seems like the device was thrown from the railway and landed in some bushes.''

"I was inside the mosque at the time, and heard an extremely loud bang.

"It frightened the life out of me, and before I knew it, we were being told to stay inside and that an explosion had happened. As soon as I was told that, I immediately thought it would be in connection with the recent attacks against other mosques."

Ahmadul Haque, a Tipton councillor, added: "Somebody came inside the mosque shouting, 'There's been an explosion, get out now.'

West Midlands police said residents were evacuated as a precaution: "Officers were called at 1.06pm and are currently at the scene. A cordon has been set up and the immediate area has been evacuated.

"Some residents have reported finding debris in the area and finding nails. This is being investigated by counter-terrorism detectives and forensic officers at the scene."

Since the murder of Lee Rigby there has been an increase in anti-Muslim attacks. In June an explosive device went off near a mosque in Walsall.

The device was found by a member of the public in an alleyway adjoining the Aisha Mosque and Islamic Centre.

After that incident a pensioner was arrested on suspicion of causing an explosion likely to endanger life. The 75-year-old man was released on bail as counter-terrorism officers continued their investigation.

Scotland Yard's counter-terrorism unit are investigating an attack on a north London mosque which had the letters EDL daubed nearby, which are the initials of the extremist English Defence League.