A former press aide for the federal Homeland Security Department pleaded no contest Tuesday to charges that he had sexually explicit online conversations with someone he thought was a 14-year-old girl.

Brian J. Doyle, 56, who resigned from the department shortly after his April 4 arrest, faces up to five years in prison under the plea agreement. The deal calls for 10 years of probation and requires him to register as a sex offender for the rest of his life, prosecutors said. His sentencing hearing is set for Nov. 17.