A Level 3 sex offender who served 27 years in prison was arraigned yesterday on assault charges, accused of trying to rape a woman who was jogging along Plum Island Beach in Ipswich.

The arrest was made several days after the man was charged with soliciting a prostitute in Haverhill, according to the Essex district attorney’s office.

Scott A. Gagnon, 51, of Tewksbury was convicted in April 1980 in several assaults, including rape of a child with force, and one count of assault with intent to commit rape, according to the state sex offender registry. He was released from prison in 2007.

On Thursday, he was caught up during a prostitution sting in Haverhill, but was not held in custody. Haverhill police Sergeant John Arahovites said that Gagnon was arrested at 1:30 p.m. at Portland and White streets after trying to solicit an undercover police officer posing as a prostitute. He was among at least 10 people arrested. According to the district attorney’s office, Gagnon pleaded guilty to soliciting sex for a fee and paid a $500 fine.

Police said Gagnon attacked the jogger Monday about 6 p.m. on Plum Island Beach, an expanse of sand that extends for several miles, including a section in a national wildlife refuge. The woman got away and called police, and, after an investigation, Gagnon was arrested and charged with assault with intent to rape.

Town officials wanted to assure people yesterday that Ipswich remains a safe community. “We have a little juvenile vandalism in the summertime, but we don’t have street crime,’’ said Bob T. Markel, Ipswich town manager. “This is very disheartening. What has to be done to protect society against people like this? Maybe the sentence wasn’t long enough.’’

An investigation by Ipswich police and US Fish and Wildlife Service officers led authorities to Gagnon. Vehicles have to pass a guard station to enter and exit the wildlife refuge. Markel said the jogger recognized her attacker in a pickup trick and identified him to police.

Gagnon was ordered held without bail pending a dangerousness hearing tomorrow.

Gagnon made headlines last year when he was fired from a Tewksbury McDonald’s after a town resident told management Gagnon was a Level 3 sex offender. He tried to sue the resident and the restaurant, but dropped the lawsuit a week later, according to reports at the time.

According to state law, individuals designated Level 3 sex offenders are determined to “have a high risk to reoffend.’’

Michaela Stanelun contributed to this report. Guilfoil can be reached at jguilfoil@globe.com.

© Copyright 2009 Globe Newspaper Company.