An NYPD officer has been fired after allegedly assaulting a jailed homeless woman who insulted and spit on him, according to newly released police documents.

The officer, Luis Marte, was found guilty in a department trial in the 2019 beating of a woman inside a holding cell in the Bronx’s 44th Precinct. He was terminated by NYPD Commissioner Keechant Sewell last month.

The confrontation began when the woman verbally insulted the officer, allegedly calling him a racial slur and a “bald f--k,” before spitting in his direction from behind the bars of the cell.

In response, Marte rushed into the lockup, repeatedly punching the woman until he was pulled off by a sergeant, according to security footage reviewed by the department’s assistant deputy commissioner of trials, Jeff Adler. The video also shows the officer spitting on the woman as he leaves the cell.

In his report, Adler, who served as judge in the department trial, described Marte’s conduct as “unhinged” and displaying a “disturbing lack of self-control.”

The officer, who was 38 years old at the time and weighs approximately 230 pounds, “did not merely strike her once; rather, he violently beat the prisoner, without regard to the injury he could be inflicting,” Adler wrote.

Marte himself conceded his actions were improper, but said he “felt attacked at the moment, and insulted, and just belittled,” according to the decision.

Following the incident, Marte was arrested and charged with attempted assault, official misconduct and filing a false instrument – stemming from his alleged failure to properly document the altercation. That case is pending.

He initially served a one-month suspension, but was allowed to return to the force, collecting a paycheck in each of the last three years. Following a department trial that began this year, he was found guilty of improper use of force, wrongfully spitting at a prisoner, and making inaccurate entries in his report.

The police commissioner, who has final say over officer disciplinary decisions, accepted the findings, terminating Marte last month, according to the newly released records.

During the trial, a department official representing Marte said his client wasn’t a “robot,” and shouldn’t be forced to lose his job over a “human response” to being attacked.

Marte is due in court in his criminal trial next month. He did not immediately respond to a request for comment.