An off-duty NYPD officer shot during an attempted robbery in Brooklyn on Saturday has died, police said on Tuesday.

The officer, Adeed Fayaz, was allegedly shot by Randy Jones, 38, of Brooklyn, officials said.

Jones was taken into custody at a Days Inn in Nanuet on Monday night after a search that lasted nearly two days, NYPD Chief of Detectives James Essig said at a news conference.

Essig said Fayaz was shot Saturday night as he and his brother-in-law were attempting to buy a car Jones had listed on Facebook Marketplace for $24,000. The two men met up with Jones at a building on Ruby Street near Linden Boulevard in East New York around 6:50 p.m. Saturday, according to Essig.

As Jones walked the two men toward a driveway on Ruby Street, he asked them "jokingly" if they were carrying guns, Essig said. When Fayaz said they weren't, Jones put him in a headlock, pointed a gun at his head and demanded cash, which Fayaz said he didn't have, according to Essig.

After Jones pointed the gun at Fayaz's brother-in-law and demanded money, Fayaz broke away, and Jones fired at Fayaz, striking him in the head, the chief of detectives said.

Fayaz's brother-in-law took Fayaz's gun and shot at the suspect several times before Jones fled in a BMW, Essig added.

Investigators later discovered that the BMW belonged to Jones' mother, Essig said.

Their search ultimately traced Jones, his girlfriend and five children to the Days Inn in Nanuet, according to Essig.

Jones will be charged after investigators carry out two search warrants connected to the case, Essig said. His attorney information wasn't immediately available Tuesday.

In a statement, Police Benevolent Association President Patrick Lynch said his union was "deeply grateful to our detective brothers and sisters for painstakingly piecing this case together and tracking this vicious criminal to his hiding place."

"Now, the justice system needs to step up and deliver consequences. It needs to send a message to anyone else who would attack police officers or innocent New Yorkers," Lynch said. "The system has already failed too many victims. It must not fail our brother and his family."