In the early hours of March 13, police broke down the door to an apartment in Louisville. Three men — one inside the apartment and two officers trying to get in — fired guns. A police officer was wounded. Breonna Taylor, an unarmed bystander who lived in the apartment, was killed.

And none of the three men who fired has been charged with a crime.

Legal experts on Thursday said the Taylor case reveals an unresolved conflict in the law. A police tactic meant to keep officers safer — raiding homes late at night, giving occupants little or no warning — can conflict with “castle doctrine” laws meant to keep homeowners safe by giving them leeway to use deadly force against intruders.

In this case, Taylor’s boyfriend saw the police and thought they were intruders. He says he fired in self-defense. The police fired back, in self-defense against his self-defense.

The result, as in other cases, was a tragedy that the law didn’t prevent and won’t punish.

“There’s a gunfight, but no one is criminally responsible,” said Michael Mannheimer, a law professor at Northern Kentucky University. “As unfortunate and as strange as that sounds.”

On Wednesday, the announcement that the officers who shot Taylor would not face charges set off demonstrations around the country. In Louisville, two police officers were shot Wednesday night. One officer was struck in the hip and was treated and released from the hospital Thursday. The other was in stable condition with an injury to the abdomen. Police arrested a suspect but declined to comment about a motive for the shootings.

Taylor’s mother, Tamika Palmer, posted an illustration of her daughter on Instagram and wrote in the caption “#ThesystemfailedBreonna.”

Legal experts said the failures that led to Taylor’s death appear to have begun long before the police officers arrived at her apartment. They said a major cause was the Louisville police’s decision to seek a “no-knock” search warrant for Taylor’s apartment, allowing them to enter without announcing themselves as police.

To justify the “no-knock” warrant, police had told a judge that they were investigating Taylor’s ex-boyfriend for drug trafficking and they thought the ex-boyfriend was receiving packages of drugs at her home. They said they needed to enter without knocking because “these drug traffickers have a history of attempting to destroy evidence,” according to a copy of the application for the search warrant.

The warrant was approved.

That night, the three officers in plain clothes were sent to Taylor’s apartment. Daniel Cameron (R), Kentucky’s attorney general, said that although the warrant allowed them to enter without warning, the officers actually did knock and announce themselves as police.

But Kenneth Walker, Taylor’s boyfriend, has said he didn’t hear that. He said he heard only knocking, and then the door being broken down. He had a registered handgun and fired it once at the intruders.

Even after they fired back — missing Walker but striking Taylor, who was standing nearby — Walker said he did not know they were the police.

“I don’t know what is happening,” Walker said in a call he made to 911. “Somebody kicked in the door and shot my girlfriend.”

Walker’s one shot hit police Sgt. Jonathan Mattingly in the thigh and pierced his femoral artery, but the officer narrowly missed a fatal injury. Walker was charged with attempted murder and assault, but prosecutors dropped those charges in May.

Under Kentucky’s version of the castle doctrine — a home-defense provision common in many states — residents are allowed to use defensive force against someone “forcibly entering” a dwelling. These laws, which have their origins in English common law, are distinct from “stand your ground” laws, which govern how people may respond to perceived threats in public places outside the home.

Kentucky’s castle-doctrine statute doesn’t allow for the use of force against police. But Walker said he didn’t know he was facing the police, according to Louisville prosecutor Thomas Wine (D).

“It certainly does create a problem,” Wine said in May when asked about the conflict between no-knock warrants and castle-doctrine laws.

“What separated these two parties was a door,” Wine said, meaning Walker and the police. “And it’s very possible that there was no criminal activity on either side of that door because people couldn’t hear what the other party was saying.”

Cameron, the state attorney general, investigated the actions of the three officers at the scene that night — Mattingly, Myles Cosgrove and Brett Hankison. He said that Mattingly and Cosgrove had fired in response to Walker’s first shot and that their bullets struck Taylor. Cameron said the two together fired 22 shots, but it was unclear which of the officers had fired the shot that killed Taylor.

Once Walker fired, the two officers were justified in firing back, Cameron said.

“According to Kentucky law, the use of force by Mattingly and Cosgrove was justified to protect themselves. This justification bars us from pursuing criminal charges in Ms. Breonna Taylor’s death,” Cameron said at a news conference Wednesday.

“This is a tragedy,” Cameron said. “And sometimes the criminal law is not adequate to respond to a tragedy.”

Hankison, who was fired by the Louisville Metro Police Department earlier this year, was outside the apartment when the firing began. He fired 10 times, through a window and a sliding-glass door, Cameron said. None of his bullets appear to have hit Taylor, Cameron said.

Hankison was the only one of the three officers charged with a crime: He faces three counts of “wanton endangerment” because some of his shots passed through a wall and entered a neighboring, occupied apartment. None of the three people in that apartment were injured, Cameron said.

After Taylor’s death, Louisville banned no-knock warrants and passed a law requiring police to wear body cameras while serving warrants.

Taylor’s death is one of a string of cases where gunfire occurred during the execution of “no-knock” warrants. In Houston last year, two people were killed and five police officers injured during a no-knock raid on a home. No drugs were found, and police said that the search warrant had been based on false information provided by an officer.

Many police chiefs have begun to recognize the dangerous conflict that exists between castle-doctrine laws and no-knock warrants — and to sharply reduce the use of those warrants, said Chuck Wexler of the nonprofit Police Executive Research Forum. Except in extreme circumstances, officers have other options, Wexler said. For one, they could simply wait for their subject to leave the house.

“Police chiefs are asking themselves, ‘Is it worth it?’ And the answer is no,” Wexler said. “There’s so much risk involved, and there’s another way to accomplish the same thing.”