A Manassas City teen, charged with two child pornography counts for allegedly “sexting” an explicit video to his 15-year-old girlfriend, was placed on a year’s probation Friday by a Prince William County judge, who said he would consider dismissing both counts if the teen stays trouble-free for a year.

The case attracted widespread attention because of attempts by Manassas police and Prince William prosecutors to take photos of the 17-year-old’s erect penis to compare with the video sent to his girlfriend in January. The police issued a statement Friday saying that the photos were “necessary for the prosecution to explore all legal avenues of evidence collection in order to prepare for trial.”

In June, Assistant Commonwealth’s Attorney Claiborne Richardson II instructed police Detective David E. Abbott to obtain a search warrant for the teen, according to the police statement, but Abbott crossed out the words “a photograph of the suspect’s erect penis” and took other photos. The following month, Richardson directed Abbott to obtain a second search warrant for a photograph of an erection, according to the police statement. In the second warrant, filed publicly last week, the explicit words were not crossed out.

After the teen and his attorneys went public with the case, the authorities decided not to serve the second warrant or use the photos from the June warrant. The police also issued a statement saying it was “not the policy of the Manassas City Police or the Commonwealth Attorney’s office to authorize invasive search procedures of suspects in cases of this nature,” although by then they had obtained two warrants.

Instead, photos of both the male and female teens in various states of undress and a sexually explicit video were entered into evidence Friday before Prince William County Juvenile and Domestic Relations Court Judge George M. DePolo. But the face of the person in the video could not be seen, nor could any identifying marks, and Abbott said he could not say who was in the video.

The female, who had sent nude photos to the male, did not testify and was not charged.

The 17-year-old was charged with distributing child pornography and possessing child pornography, a charge reduced Friday by Richardson from manufacturing child pornography.

Richardson said that the explicit items were found on both the male and female’s cellphones and that data on the photos and video had the mapping coordinates of the male’s home. The prosecutor also noted that sexually explicit text messages between the teens were sent at the same time as the videos and photos.

Saying that teens and adults alike use each other’s phones, the teen’s attorney, Jessica Harbeson Foster, argued that the explicit photos and video could have been of anyone. She also argued that the prosecution was misguided as a policy matter. “The goal [of the law] was to protect children from injury,” she said. “The problem is, here, there is no victim, because it’s very clear from the text messaging that these two had a consensual relationship. It’s not illegal for them to have a sexual relationship. . . . This is a law to protect juveniles, not to prosecute them, not to create more harm.”

DePolo said: “I don’t see the case the way the defense does. But on the other hand, I don’t want to see a young man start off with any convictions.”

He continued, “The court finds facts sufficient on both counts” to convict the teen, “but the court is not going to make a finding at this time.” He suspended imposition of any ruling for one year, placed the teen on probation, and ordered him to perform 100 hours of community service and have no access to text messaging or social media of any kind.

The judge said, “The defendant shall not be placed on the sex-offender registry or any similar lists.”

DePolo set a hearing for next August. “Assuming the defendant complies with everything I’ve articulated,” he said, “the cases will be up for possible dismissal at that time.”

Richardson quickly left the courtroom through a rear hallway and could not be reached later. Reports of death threats against him and Abbott caused the courthouse to be on a higher-security alert Friday.

Foster said she was “reasonably happy” with the ruling, though she noted that “the persons that were depicted in the photos and videos were not identified. And it was never identified as” her client. The Washington Post generally does not name juvenile defendants.

The teen defendant said: “I don’t know how to feel about it yet. It hasn’t sunk in. . . . I feel good about the sentence, but then again, I feel bad because we didn’t need to get involved in all this. . . . They just blew it all out of proportion.”

The statement issued by Manassas police said that it had never been the policy of Prince William prosecutors to seek a permanent conviction for a juvenile in peer-to-peer sexting and that county officials had never sought to place such juveniles on the sex-offender registry. But the statement said juveniles, and their attorneys, “must agree to such dispositions in order to avoid a trial,” and added, “Our police and prosecutors recognize the unique responsibility we have to protect our young people, even sometimes from themselves.”