NEW YORK - A Bangladeshi imam and his assistant were killed after a gunman opened fire close to a New York mosque, with angry residents calling it a targeted shooting and police promising investigation as a possible hate crime.

Eyewitnesses said that gunshots rang out Saturday afternoon near the Al-Furqan Jamia Masjid in Queens, a borough of New York City, leaving both victims lying on the ground in their own blood just a block from the mosque.

Police later said the imam, Maulana Akonjee, 55, and Thara Uddin, 64, were fatally wounded.

Friends of Imam Akonjee, who moved here from Bangladesh two years ago, told media he had just left the mosque after prayers when he was shot. The mosque serves the large Bangladeshi community in Ozone Park, Queens.

Dozens of people from the nearby Muslim community gathered at the scene to demonstrate, chanting ‘We want justice’. Some of those attending the rally said the shooting was a hate crime, although police said they were still investigating the motive.

"These were two very beloved people," Afaf Nasher, executive director of the New York chapter of Council on American Islamic Relations (CAIR), said. "These were community leaders.

"There is a deep sense of mourning and an overwhelming cry for justice to be served," Nasher said. "There is a very loud cry, too, for the NYPD (New York Police Department) to investigate fully, with the total amount of their resources, the incident that happened today."

The organisation held a news conference on Saturday evening in front of the mosque, the Al-Furqan Jame Masjid, where the two men had prayed.

"We are calling for all people, of all faiths, to rally with compassion and with a sense of vigilance so that justice can be served," Nasher said. "“You can’t go up to a person and shoot them in the head and not be motivated by hatred.”

The suspect was seen by witnesses fleeing the scene with a gun in his hand, police said.

The imam's daughter, Naima Akonjee, said her father and Thara Uddin were close friends who always walked together to the mosque from their homes on the same street. ."We are currently conducting an extensive canvass of the area for video and additional witnesses," Deputy Inspector Henry Sautner said in a statement.

Eric Phillips, a press secretary for New York City Mayor Bill de Blasio, said the mayor was closely monitoring the police investigation into the shootings. "While it is too early to tell what led to these murders, it is certain that the NYPD will stop at nothing to ensure justice is served,” Phillips said in a statement.