He was facing departmental charges stemming from a prior argument with his estranged wife.

A cop stripped of his gun and facing departmental charges stemming from an argument with his estranged wife killed himself with another cop’s gun in an office in Brooklyn Criminal Court yesterday morning, police said.

Officer Leonard Hinds shot himself in the head when he showed up for work yesterday at 6:10 a.m. in a first-floor office inside the Schermerhorn Street courthouse, using a key to open a locker holding a gun belonging to another officer.

Sources say Hinds apparently had a telephone argument late Thursday night with his wife, who was in Virginia.

There were no previous indications the 30-year-old officer was depressed and contemplating killing himself.

In fact, sources said, the NYPD had decided to return Hinds to full duty – and to return his gun to him – pending the outcome of his case, which was not likely to result in harsh discipline.

Hinds’s lawyer, Stu London, said the cop was looking forward to returning to work.

Hinds, buoyed by the news, nearly retrieved his weapon on Thursday, but arrived too late at Police Headquarters to get it, sources said.

The cop, still dressed in civilian clothes, shot himself once in the head and died at the scene while nearby officers rushed to his aid when they heard the shot.

The shooting sparked an investigation into how Hinds got the key. It was not immediately clear if the owner of the gun, another officer whose name was not released, failed to secure the key.

Hinds, a father of three, initially got into hot water when police in upstate Oneonta responded to a call of a domestic dispute at his estranged wife’s home last Nov. 30, though it was not immediately clear what the argument was about.

Hinds was hit with NYPD departmental charges because he did not tell Oneonta officers he was a cop, as required under NYPD rules, and he did not tell his superiors about the incident, police said.

The NYPD also charged him with moving – from one part of New York City to another – without notifying the department, police said.

Hinds is the second cop to kill himself this year. Five cops committed suicide last year.