ROCKLAND, Maine — A judge rejected a plea for leniency and sentenced a Washington man Thursday to 30 days in jail for sexual contact with a 15-year-old girl.

Judge Susan Sparaco agreed to the recommendation of Assistant District Attorney Jeffrey Baroody and sentenced Keith Foster to 364 days in jail with all but 30 days suspended for sexual abuse of a minor. Foster will be placed on probation for a year and be registered for 10 years as a sex offender.

Foster was 20 years old when he had the sexual contact with the girl who was 15 years old.

The prosecutor said Foster knew the girl was 15. The two had exchanged graphic sexual texts and photographs. The girl’s mother discovered the texts and contacted police, he said.

Foster denied having sexual intercourse with the girl but admitted to fondling her genitals, the assistant district attorney said.

Defense attorney Jeremy Pratt asked for a seven day jail term, the same as another sentence imposed in Rockland District Court for a case in which the girl became pregnant by the sexual activity.

The relationship would not have been a crime if Foster was 6 months younger or the girl was 6 months older, Pratt said. He also said the girl’s father was aware of the relationship.

“The stigma of a conviction is significant enough of a punishment,” Pratt said.

But Baroody argued that the longer jail time was warranted to send a message both to Foster and to other people his age who consider committing such actions. He said state law makes it a crime for someone to have sexual contact with a 15-year-old if the older person is 5 years or more older than the other party. The law is in place, Baroody said, to prevent the older person from taking advantage of the younger person.