Two days after an imam and his assistant were gunned down after afternoon prayers in Queens, the police said late Monday that a man they had in custody had been charged in the killings.

The man, Oscar Morel of Brooklyn, 35, who was taken into custody late Sunday after the police connected him to a hit and run that occurred about a mile away from the fatal attack, faces two counts of second-degree murder and two counts of criminal possession of a weapon, the police said.

A police official said investigators had found what they believe was the murder weapon in the man’s home as well as clothes matching the description of what the gunman had been wearing during the shootings. The official, who spoke on the condition of anonymity, said the gun was found inside a wall in his apartment, on Miller Avenue in the East New York neighborhood, in a cavity that had apparently been cut open and resealed.

A man who answered a phone listed for Mr. Morel’s family said that he was stunned by the arrest. “That is our relative,” the man said, his voice soft and shaking with emotion. “We are just finding out ourselves. We’re pulling together the pieces as well.”