Allen Ivanov told authorities that he showed up at the Washington state home late Friday night, according to documents.

He parked across the street, he told investigators, and he watched.

Ivanov “creeped up” toward the Mukilteo, Wash., home, the probable cause affidavit states. Presumably, he saw his ex-girlfriend, Anna Bui, with a man. The name is mostly redacted in the document — a person identified only by a letter: A.

What Ivanov saw made him angry, he told authorities. So the 19-year-old went back to his car, and he read the instruction manual for the AR-15 semiautomatic rifle that he had purchased about a week ago, according to the affidavit.

Then, Ivanov told investigators, he loaded the gun, went back to the home and, later, he began to fire.

Ivanov was taken into custody in the wake of the weekend shooting at the suburban Seattle home, which left three people dead.

Bui was killed, along with Jordan Ebner and Jake Long, according to the Seattle Times. All three were 19. A fourth person, 18-year-old Will Kramer, was wounded.

Ivanov faces three counts of aggravated first-degree murder and one count of attempted first-degree murder, according to court documents. He has also been charged with one count of first-degree assault.

Ivanov has confessed to the shootings, according to the probable cause affidavit.

“Ivanov stated that everything that went on tonight was about a girl,” a detective wrote in the documents. He called Bui, whom Ivanov said he had dated for about a year and a half, his “dream girl.”

Ivanov was being held without bail, the Times reports. One of his attorneys, Tim Leary, said his client was “in a state of shock.”

“I think he is being made aware of the very long road that he has in front of him,” Leary told The Washington Post in a phone interview.

The case brought up larger questions about how Ivanov was able to get his hands on the gun in the first place, he also noted.

“There’s something that’s broken,” Leary said. “It’s not like I have the solution. But it sure seems like there needs to be a greater discussion.”

The shooting happened early Saturday morning, shortly after midnight, according to the probable cause affidavit. A witness told authorities that about 20 people had gathered at the home for the party.

“He said that he was inside the garage getting some water when he heard a loud banging sound, which he initially thought were fireworks,” the probable cause affidavit reads, recounting a witness’s testimony. “He said that he opened the garage door, and heard screaming and saw people running. At that moment he recognized that the banging had been gunshots.”

The witness looked up, he told investigators, and saw Ivanov pointing a rifle at him.

“He said that he started to run, and he felt a bullet hit the ground near his foot,” the documents state.

A state trooper took Ivanov into custody, and he was later interviewed by detectives.

Ivanov told investigators that he broke up with Bui about two months ago, saying he had “thought he needed some time to work on himself.” After the break-up, Ivanov told detectives he received Snapchat posts from Bui that indicated that “she was getting on with her life without him, which made him jealous.”

Ivanov started to think the split was a mistake, he told detectives. Recently, he started to spend time with Bui again but grew angry when he heard that she was also “seeing other guys while the two of them were talking,” a detective wrote in the affidavit.

He bought the AR-15 about a week ago, the affidavit notes, and told investigators that he had planned to attend a gun safety class this month and take the firearm to target practice.

“He admitted that to him, the rifle was a symbol of power,” the documents state.

On Friday night, after he had read the gun’s instruction manual, Ivanov told investigators that he “creeped around the back side of the house,” then hid along a wall.

“Ivanov stated that while he was in his hiding place, he was discovered by a male partygoer,” the documents state. “The male said, ‘no, no, no.’ Ivanov stated that he was ‘scared,’ he flipped the selector switch to fire and shot the male. He stated that at that point it was too late to turn back, and once he had pulled the trigger his adrenaline kicked in.”

He walked through a side door and said he shot Bui twice, then kept moving through the home. He told investigators that he shot a man who was running toward the home and then went upstairs. He fired down from the home’s balcony, went to the roof, and realized that the rifle’s magazine was empty. That’s when he went back to his car and drove away, according to the documents.