PORTLAND, Maine — A Rhode Island man was sentenced Tuesday in U.S. District Court to 20 months in federal prison for crossing state lines to have sex with a minor, according to the U.S. attorney’s office.

William McNeill, 23, of Cumberland, Rhode Island, was also sentenced to five years of supervised release, the federal prosecutors’ office said. Conditions of supervised release include registering for life as a sex offender and restricted access to minors, computers and the internet.

McNeill had been held without bail since pleading guilty in March.

In the fall of 2014, McNeill met a 14-year-old Cumberland County girl online, according to the prosecution version of events to which he pleaded guilty. On about Oct. 18, 2014, after several weeks of communicating with the teenager in a sexually explicit manner, McNeill traveled from North Carolina, where he was serving in the U.S. Marine Corps, to Maine to meet her.

The matter came to light when the girl, fearing she was pregnant, spoke to a school counselor and said she had been raped by a stranger, according to court documents. The counselor reported the allegation to the police, as required by Maine law. An investigation led the Bridgton police to McNeill.

McNeill faced up to 30 years in prison and a fine of up to $250,000.

To reach a sexual assault advocate, call the Statewide Sexual Assault Crisis and Support Line at 800-871-7741, TTY 888-458-5599. This free and confidential 24-hour service is accessible from anywhere in Maine. Calls are automatically routed to the closest sexual violence service provider.