A man has been arrested and will be charged in the fatal shootings of two homeless men in Las Vegas and the attempted murders of two other people, and police said the shootings appear random.

Las Vegas police said Tuesday that Joshua Castellon, 26, will be booked on two murder counts and two attempted murder counts in connection with the shootings in late January and early February which sparked fears that serial killer someone was targeting the city's indigent.

"[The] good news is, we have a suspect in custody and we're relieved that a dangerous person is off the streets," Las Vegas Metropolitan Police Department Capt. Robert Plummer said at a news conference.

Castellon agreed to an interview and was detained Friday by the federal Bureau of Alcohol, Tobacco, Firearms and Explosives on a weapons charge, police said. Police have submitted an arrest warrant for the shootings.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"I wouldn’t be able to explain a motive on why somebody does this. But he did not explain a motive," police Lt. Dan McGrath said. There is no known connection between the suspect and victims and "it appears totally random," he said.

Joshua Castellon LVMPD

The first fatal shooting occurred sometime before around 3 a.m. (6 a.m. ET) Jan. 29 when a homeless man was shot to death while sleeping outside a business. At around 7:16 a.m. that morning a homeless man was taken to a hospital after being shot in the mouth and jaw area. He survived.

Then on Feb. 2 a homeless man was fatally shot under a bridge and surveillance video captured a man walking up to the victim and opening fire, police said. It was later determined that on Jan. 29 another man cleaning a car wash was shot at by someone in a vehicle, and he survived, police said.

A federal complaint shows that on Feb. 15 detectives contacted Castellon's estranged wife, according to the Associated Press. She told police she believed her husband had purchased a revolver in January.

A day later, officers stopped Castellon, and he agreed to a formal interview. He told detectives he had purchased a revolver to resell it to a "friend of a friend," according to the complaint. Federal records do not list an attorney for Castellon.

Castellon was linked to the killings in part after a patrol officer found him sleeping in a car and interviewed him on Feb. 8, and it was also determined that a police officer ran his plate around 30 minutes before one of the shootings, which placed him in the area, McGrath said.

Castellon was arrested for allegedly purchasing the gun, but the handgun believed to have been used in the shootings has not been recovered, police said. Investigators are asking that anyone who had contact with Castellon, who is not homeless but sometimes slept in his car, contact police.

Tips from the public and other parts of the investigation led police to begin focusing on Castellon on around Feb. 14, McGrath said.

Castellon is described as local, and while police don't believe the handgun used in the shootings was used in any other attacks, they are checking to see whether there are any other unsolved shootings in neighboring states, McGrath said.

Castellon doesn't have much of a criminal history, McGrath said. He had a recent domestic violence incident and a breakup, and had been staying with friends and family and sometimes sleeping in his car, McGrath said.