More than 300,000 people took part in mass prayers in Sholakia, 62 miles (100 kilometers) northeast of the capital Dhaka, when the attack was launched at the checkpoint, Kishoregunj District Police Assistant Superintendent Shoaib Abu Shayal said.
The violence has shaken the country, as it appears to be the first attempt at a major attack directed entirely at Muslims.
"The attackers' target was the congregation but the police were able to stop them from crossing the checkpoint," Bangladeshi Information Minister Hasanul Haq Inu told CNN.
The Eid-al-Fitr festival celebrates the end of Ramadan
, when Muslims break their fast and celebrate with their families, friends and communities.
One police officer and a female civilian died in an exchange of gunfire, police told CNN, while another officer was wounded and died later at a hospital. As many as 14 other officers were injured.
Police told CNN the perpetrators attacked the checkpoint, which was set up about a kilometer from the gathering, and took shelter in a house after fighting broke out. Police then surrounded the house and searched the area, they said.
The information minister said the operation had ended. One of the attackers was killed and four others were taken into custody, he said.
Thursday's attack comes less than a week after 23 people were killed in a terrorist attack on a popular bakery in Dhaka
, an act of violence which shocked the country.
Bangladesh has for years struggled to stop a series of deadly hackings of secular thinkers, LGBT activists and religious minorities carried out by Islamist groups.
"It is not yet clear who was behind (Thursday's) attack but these terrorists are against the true religious practices of Islam and against the secular democratic government of (Prime Minister) Sheikh Hasina," Inu told CNN.
"Eid congregations all across Bangladesh were peaceful except this incident."
The militant group ISIS called for attacks throughout the holy month of Ramadan, but no one has yet claimed responsibility for Thursday's attacks.
There are several groups in Bangladesh affiliated with ISIS and al-Qaeda, competing for influence in the South Asian nation.
A day before the event, police said they had put strict security measures in place, including uniformed and plain clothes officers as well as closed circuit security cameras.
Attendees were searched before they entered the premises.