Inset (left): Omar Andres Ramos Castro (Ramsey County Jail). Inset (right): Gabriel Arrazola Perez (EverLoved.com). Background: News footage of the area in St. Paul, Minn., where Gabriel Arrazola Perez was found on May 25 (KARE).

A Minnesota man allegedly stabbed a beloved member of the Twin Cities community and left him to die on the train tracks.

Omar Andres Ramos Castro, 24, was arrested on June 4 and charged with second-degree murder days after the body of 44-year-old Gabriel Arrazola Perez was found on a set of railroad tracks in St. Paul, Minnesota. According to a criminal complaint reviewed by Law&Crime, Perez was found on May 25, when a man's English bulldog started pulling him toward the body's location. The man, who immediately called 911, told police that the body had not been there the day before.

When police arrived, they found an eyeglasses prescription and a driver's license identifying the body as Perez, a well-known barbershop owner in St. Paul. The dead man's Subaru Crosstrek was found about half a mile away.

According to the complaint, Perez's family told police that they last saw him at a gathering at a local brewery at 4 p.m. on May 24. After he left the gathering, no one heard from him again. But when investigators obtained his phone records, they saw that Perez called someone three times in the hours after he left the brewery. The same person called him back at 6:34 p.m.

Investigators then obtained surveillance video of the train tracks where Perez was found. Police wrote that between 8:55 p.m. and 11:12 p.m., Perez's body was "clearly visible" after it had not been seen there earlier. Videos allegedly captured Perez and another man walking around the train tracks at 7:03 p.m.

Police said the cellphone number Perez was calling was tracked to the location where Perez was seen with the other man before, during, and after the alleged crime took place.

Perez's phone was later found by police and a K-9 unit; fingerprints on the phone did not match Perez. Further inspection of the phone determined that the person Perez was contacting sent Perez a pin location on WhatsApp, close to the location where Perez was found dead.

Additional surveillance video from a nearby Speedway convenience store captured a man wearing the same clothing as the man who was with Perez at the train tracks. The man, eventually identified as Ramos Castro, was tracked to his apartment, where he was arrested and taken to the police station for questioning with the assistance of a translator.

After Ramos Castro was read his rights, he initially said that he had only met Perez once, when Perez offered him work clearing construction debris from his home. He denied a friendship or relationship with Perez. Ramos Castro's story evolved, and police said he admitted he had received a few calls from Perez inviting him to get food or smoke marijuana. He denied that Perez was making sexual advances.

According to the complaint, that story also changed. After Ramos Castro denied seeing Perez on May 24 and denied being at the train tracks that day, he was confronted with the evidence that allegedly put him at the scene. Ramos Castro then claimed he was with Perez for about 10 minutes, and there were other people with them. He claimed to police that he left Perez there alone.

More from Law&Crime: Man claimed he and his wife were stabbed by an intruder until cops noticed someone very familiar-looking on his Ring camera: Police

After further questioning, Ramos Castro eventually admitted that he and Perez had an "encounter" at the train tracks. Police said Ramos Castro claimed that Perez made "unwanted sexual advances toward him," including allegedly reaching for his crotch. Ramos Castro claimed that he became "filled with rage and felt he had to defend himself."

Police said Ramos Castro admitted to stabbing Perez with a pocketknife, but could not remember how many times because he was "so overwhelmed by anger."

According to the criminal complaint, Perez had several defensive wounds in addition to the stab wounds to his back, neck, chest, and abdomen. The medical examiner determined that Perez's "large bowel was eviscerated," and he had stab wounds that caused fractures to three vertebrae in his neck and back.

Ramos Castro was charged with second-degree murder. He is being held at the Ramsey County Jail on $2.5 million bond. His first court appearance was scheduled for Monday.