Westbrook High School’s girls’ track coach admitted having a sexual relationship with a 17-year-old student whom he had coached after police confronted him with lurid text messages the two had exchanged, according to court papers released Wednesday.

Timothy Even, 27, who has been held without bail at the Cumberland County Jail since his arrest Monday, was expected to be released on $2,500 cash bail following his first appearance Wednesday in Portland Unified Criminal Court, said his attorney, Thomas Marjerison.

Even at first denied having an inappropriate relationship with the student, but acknowledged it once he was shown copies of the texts, according to court filings.

“This is a situation that started with the best of intentions,” Even wrote in a signed affidavit. “Unfortunately my lack of professionalism and self-control created a situation that got out of hand.”

The relationship came to light after a friend of the victim saw text messages on the victim’s phone from “Tim,” became concerned and, along with her parents, contacted the Westbrook police.

Court records allege the two had sex four times between April 8 and Sept. 17, including at Even’s home in Portland, at a summer camp in Stoneham where Even worked, and most recently in a public park near the former Catherine McCauley High School, now called the Maine Girl’s Academy, on Stevens Avenue in Portland. Westbrook police said the relationship began in April.

Prosecutors had asked for $50,000 cash bail. But Judge Andrew Thornton agreed Wednesday to accept the lower amount suggested by Marjerison, acknowledging Even’s lack of a criminal record and limited means.

Conditions of Even’s release include having no direct or indirect contact with the alleged victim and only supervised contact with minors under age 18. He is also forbidden from going onto the property of Westbrook High School.

Even is charged with four counts of gross sexual assault, a Class-C felony that carries a maximum penalty of five years in prison and a $5,000 fine. Although the age of consent in Maine is 16, state law prohibits teachers or school employees from having sexual relationships with students over whom they have disciplinary or supervisory authority.

Even was initially charged with three counts of gross sexual assault, but an additional count was added at the hearing.

In his police interview, Even admitted knowing it was illegal and inappropriate for a teacher to engage in a sexual relationship with a student, but said he couldn’t control his feelings, according to police reports. Even handed over his Westbrook High School ID badge and agreed to allow his personal cell phone to be searched before being taken into custody.

In addition to coaching, Even has been a full-time ed tech for three years in the district and is an adviser for the Westbrook Class of 2018.

Even, originally from Stoneham, began coaching at Westbrook High in 2013. Before that, he was an assistant cross country and track coach at Fryeburg Academy, his alma mater.

He has been involved in Camp Susan Curtis, a nonprofit summer camp for economically disadvantaged youth, since 2004.

Melissa L. Cilley, executive director of the Susan L. Curtis Charitable Foundation, said Even was a seasonal employee who started as a dishwasher and worked his way up to assistant director of the 10-week summer program.

Cilley said that Even, like all the camp’s staff, shared a commitment to helping disadvantaged Maine youth.

His profile on the Camp Susan Curtis website and his Facebook page indicate he earned a bachelor’s degree in music from the University of Southern Maine, but the USM registrar said Even has not been awarded a degree, though he has enough credit hours to be considered a senior. He was last enrolled in a class at USM in December 2014.

Westbrook School Superintendent Peter Lancia said Even listed a bachelor’s degree from USM on his resume and had indicated on his job application that he expected to complete the degree in 2014. Lancia said in an email that Even held current ed tech certification and had completed a state background check. Ed techs are not required to have a bachelor’s degree. Even was placed on administrative leave by the school.

Even’s next court appearance is scheduled for December.