An NYPD chief fatally shot himself in the head while sitting in an unmarked patrol car on Wednesday, just weeks before his scheduled mandatory retirement, sources said.

Steven Silks, the deputy chief of Queens North, was found shot in a parking lot just blocks from his office at the 112th Precinct Station house at about 6:30 p.m., according to law enforcement sources.

The 62-year-old chief was taken to Elmhurst Hospital, where he died.

“It’s terrible he would find himself in that place,” a Queens detective said at the scene. “Say a prayer for his family.”

Another police source told The Post that Silks “absolutely lived for the NYPD.”

“He loved what he did. He was admired and loved by everybody. It’s heartbreaking,” the officer said.

Silks handed in his paperwork at an NYPD union office on Tuesday, sources said. His last day was scheduled to be July 9.

The NYPD’s mandatory retirement age is 63.

President of the Detectives’ Endowment Association Michael Palladino said he was “shocked and saddened” to hear about the death of Silks.

“He had such enthusiasm for the job and for life itself which makes this difficult to understand,” Palladino said in a statement. “He was one of the nicest human beings I ever met.”