A man who was shot in the head by a police officer Tuesday night inside a Northwest Washington home was in violation of a judge’s protective order when the shooting occurred, according to authorities and court documents.

The man’s ex-wife had called police after receiving a threatening text message, authorities said. The woman did not know that her ex-husband had entered her Brightwood home through a rear window and was hiding in the basement when she called 911 about 11:20 p.m., police said.

Officers responding to the call searched the house, in the 6400 block of 13th Street NW, and were ambushed in the basement. A police report said the man, armed with a knife, jumped from under a stairway and stabbed one officer twice in the back, piercing his protective vest. During the attack, another officer shot the man once in the head.

The injured officer suffered two puncture wounds and was treated at a hospital and released. The man who was shot, identified as David Valentine Young, 46, of Northwest Washington, was in serious condition at a hospital. Police said he has been charged with burglary, felony assault on a police officer and contempt of court.

Court documents describe several altercations inside the house dating to 2010, when the couple divorced. “This was an ongoing, long-standing domestic case,” D.C. Police Chief Cathy L. Lanier said Wednesday.

Neighbors say they have repeatedly complained about the house’s occupants to the landlord, police, their D.C. Council member and other city officials. They cited loud parties, overgrown grass, visitors at all hours and arguments on the front lawn.

“I am disgusted to look out my window and see 20 to 25 police cars,” Gerri Adams-Simmons, past president of the Brightwood Community Association, said Wednesday of the scene across the street from her home Tuesday night.

Adams-Simmons, who has been active in the District’s political circles, said she marched from her house in her pajamas and confronted Lanier, who confirmed the encounter. The neighborhood activist said her message was as blunt as it was succinct: “They got to go.”

Records on file in D.C. Superior Court show that Young’s ex-wife obtained two-week protective orders in 2010 and 2011. She alleged being choked and threatened. She also said she found bullet holes in a wall and bedroom door, the records show.

In January, a judge issued a year-long protective order against Young after allegations of sexual abuse involving children, court documents show. The documents say D.C. police were investigating. None of the complaints since 2010 have resulted in criminal charges.

A man who came to the door of the house Wednesday declined to comment.