PITTSBURG -- Just before jury selection was set to begin, a Contra Costa County trial judge on Wednesday dismissed a criminal case against a 20-year-old Antioch man for having consensual sex with his 16-year-old girlfriend when he was 18.

"I have never made this ruling before," Judge Nancy Stark said. "It's not in the best interests of society to pursue this case."

The misdemeanor case, taken on by the county's top public defender, represents a disturbing trend in Contra Costa County of statutory rape prosecutions involving consensual sex by teenagers with a small age difference, defense attorneys say. But a head sex crimes prosecutor said there's no uptick in such prosecutions; the District Attorney's Office is just doing business as usual.

The Antioch man, a college student who asked not to be identified to protect his privacy, was charged in August 2011 with three counts of unlawful sex with a minor -- colloquially known as statutory rape -- and three counts of oral copulation on a person under age 18. He said the case put him in jail for 12 days, cost him a job at FedEx and forced him to take a semester off school. Around Antioch, he said, he was treated as if he were already a convicted sex offender.

"That's not who I am, that's not who I was raised to be," he said Wednesday outside a Pittsburg courtroom, where down the hall a 19-year-old East County man was facing felony charges for having consensual sex with a 16-year-old girl. That 19-year-old had just been accepted into the Army before the case was filed this year, and the charges derailed his military plan, which included studying at West Point, his attorney said.

Police brought the Antioch case to the District Attorney's Office in 2011, when, in the course of an investigation into a burglary at the girlfriend's house that spring, an officer learned that the one-time high school sweethearts were sexually active. Especially damning to the then-18-year-old: Detectives found his cellphone contained a video of the girl performing oral sex.

The girl told the officer she thought the sex was legal and that it was only a crime if her partner was at least five years older. She didn't want him to be prosecuted, Public Defender Robin Lipetzky said.

Deputy district attorney Adam Wilks said the girl cooperated with the prosecution, and asked for a restraining order against the defendant after they broke up around the time of his arrest.

The age of consent in California is 18. Still, a statutory rape prosecution involving a two-year age difference seemed so odd that it sparked rumors among defense attorneys that the District Attorney's Office had received grant money to pursue statutory rape convictions.

Not true, said senior deputy district attorney Nancy Georgiou, who heads Contra Costa County's sexual assault unit.

"There's no special initiative, no funding. Nothing's changed over here," Georgiou said. "The Legislature defines what conduct is criminal and the penalties. Police bring in the cases, and if we can prove a crime that is something the Legislature says needs to be regulated, we'll pursue it.

"The laws are there to protect young teenagers from the consequences of making immature or uninformed decisions about sex and to protect teenagers from manipulative adults."

Wilks argued that a prosecution would deter the defendant and society at large from engaging in inappropriate sexual relationships with minors. The defendant filmed the girl without her consent and later threatened to distribute the video if she didn't cough up money for a pair of new shoes, Wilks said.

"The conduct here is not as innocent as the defense or court makes it seem," Wilks said in court.

Judge Stark said she couldn't see the value to society in going forward. She didn't want the man to be stigmatized for the rest of his life as a sex offender.

The man and his family members broke down in tears of relief.

Contact Malaika Fraley at 925-234-1684. Follow her at Twitter.com/malaikafraley.