Police arrested and charged a man with murder over the fatal shootings of an imam and his friend as they left a New York City mosque over the weekend.

Oscar Morel, 35, was charged with two counts of second-degree murder and two counts of criminal possession of a weapon, police said.

Morel, who police said hit a cyclist with his SUV just 10 minutes after Saturday's shooting in Queens, was taken into custody late on Sunday night, said the New York Police Department's chief of detectives, Robert Boyce.

READ MORE: Leaders of the Ahmadiyyah mosque vow 'not to let hate prevail' in wake of Asad Shah murder

Morel could be seen on the surveillance video fleeing the area of the shooting in a black GMC Trailblazer after Imam Maulana Alauddin Akonjee and Thara Uddin were shot in the head, Mr Boyce said.

About 10 minutes later, a car matching that description struck a cyclist about three miles away in Brooklyn, he said.

Morel was arrested outside a Brooklyn flat after he intentionally rammed his car into an unmarked police cruiser trying to block him in, Mr Boyce said.

Charges against the Brooklyn man were upgraded on Monday night after police said they recovered a revolver at his home and clothes similar to those being worn in a surveillance video that showed the gunman.

Earlier on Monday, about 1,000 people gathered under tents to praise Mr Akonjee, 55, and Mr Uddin, 64, at an Islamic funeral service where emotions ran high.

The ceremony featured several speakers who said they believed the victims were targeted because of their religion. Some members of the congregation shouted "justice" throughout the service.

After the ceremony, part of the crowd marched to the spot where the shooting took place.

Mayor Bill de Blasio told those gathered that the entire city was "mourning with you".

READ MORE: Leaders of the Ahmadiyyah mosque vow 'not to let hate prevail' in wake of Asad Shah murder

The authorities have not revealed a motive for the killings, though Mr Boyce said the possibility that the murders were a hate crime is "certainly on the table".

Some in the largely Bangladeshi Muslim community in Queens and Brooklyn have described harassment in recent months by people who shouted anti-Muslim epithets.