Image copyright AP Image caption Two police officers were killed in the attack

Militants have attacked police guarding the largest Eid gathering in Bangladesh, throwing homemade bombs and launching a gun attack.

About 300,000 people had gathered for Eid prayers at the Sholakia field in Kishoreganj district when the attack on a security checkpoint began.

Police say four people, including two officers and one attacker, were killed.

Last week, militants stormed the Holey Artisan Bakery cafe in Dhaka, killing at least 20, most of them foreigners.

That attack was claimed by so-called Islamic State (IS), although the government said the attackers belonged to a local militant group.

No group has said it carried out Thursday's attack.

Eyewitnesses said four militants had used machetes and guns to attack police.

The imam leading prayers at the Sholakia field had recently issued a decree against killing in the name of Islam.

After the attack, he told journalists: "The young men who think they will go to heaven [by carrying out attacks] are wrong. They will go straight to hell."

'Protect our children'

Information Minister Hasanul Haq Inu told the BBC Bengali service that the high level of preparedness of security forces had prevented an attack on the prayer congregation.

"We have been able to either capture or destroy most of the terrorists," he said.

Police were investigating the attack and did not rule out "IS, al-Qaeda, or the Taliban" as possible groups, "but we still do not have any evidence to suggest that Bangladeshi militants have any organisational link with foreign groups," he added.

Image copyright AFP Image caption The attack came as Muslims across Bangladesh gathered for Eid prayers

Image copyright AP Image caption Police had been deployed to guard Eid prayers at the Sholakia field

There have been security fears in Dhaka following last Friday's attack on the cafe.

There were tight checks at some Eid services in the capital, with scanners and sniffer dogs used to check for bombs before worshippers could enter, AFP reported.

Many people could be seen weeping during the services, while a local cleric issued a prayer to "protect our children from the evils of terrorism", AFP added.

Bangladesh has also seen a spate of attacks on secular bloggers, gay activists, academics and members of religious minorities, with more than 40 killed since February 2013.

Many of those attacks were claimed by Islamic State militants or al-Qaeda affiliates, although the government has blamed local groups and the opposition instead. The opposition denies the claims.

Speaking on Thursday, Hasanul Haq Inu told the BBC that recent attacks were "isolated incidents through which some youngsters are taking the wrong path".

"Militant terrorism is not a trend in Bangladesh, it is still not a trend," he said.