A 24-year-old man has pleaded guilty to two high-profile sexual assaults earlier this year in the Hyattsville-Mount Rainier area, authorities said Monday.

Edwin Xavier Rivas, who is listed as having a New York address, pleaded guilty to first-degree rape in connection with a Jan. 28 attack at a Mount Rainier apartment complex and to fourth-degree sex offense and second-degree assault in connection with a Feb. 23 incident in Hyattsville, court records show. He is scheduled to be sentenced Nov. 21, where he will receive an 18-year prison sentence as part of his plea deal, said John Erzen, a spokesman for the Prince George’s County State’s Attorney’s Office.

Police arrested Rivas in May, charging him in connection with the two incidents and said they were exploring whether he was responsible for others in a series of attacks on and around the Northwest Branch Hiker/Biker Trail. From late January through mid-April, six females were attacked, four of them raped, as they walked along the trail and in the apartment complexes, parks and neighborhoods that it connects.

In the Jan. 28 incident, police have said, a man with a knife accosted a 19-year-old woman in the 3300 block of Buchanan Street, then threw her into bushes and raped her. In the Feb. 23 incident, a man forced a woman into the woods off Jamestown Road and told her to remove her shirt, police have said.

Erzen said investigators probed whether Rivas was responsible for other attacks, but “it only ultimately came back on these two victims.” He said that Rivas admitted responsibility for the Jan. 28 incident, and investigators further linked him to the crime with DNA evidence. In the Feb. 23 incident, Erzen said, Rivas’s victim was able to identify him from surveillance footage at a nearby convenience store.