CONCORD, N.H.  — A Somersworth man has been sentenced to 20 years in federal prison for having a sexual relationship with a 13-year-old Maine boy and for possessing child pornography.

Scott Wilson was also sentenced Tuesday in U.S. District Court in Concord to probation for the rest of his life and was ordered to register as a sex offender upon release.

Authorities say the 41-year-old Wilson met the boy on a social networking site in 2004.

Prosecutors say Wilson and the boy communicated via email and instant messaging and arranged to meet. Wilson travelled to Maine, met the boy, and brought him back to New Hampshire where they engaged in sexual activity in Wilson’s home.

A search of his home computer turned up child pornography on his computer.

The boy’s mother alerted authorities.