For her new song, pop star Selena Gomez sought help from a Mainer.

Gomez’s single “Back to You” was co-written by Maine singer songwriter Amy Allen. The single was released Thursday and will be featured on the soundtrack of the popular Netflix series “13 Reasons Why.”

The song is the first foray into the pop music charts for Allen, who moved to California several months ago. But she says the song is also “deeply personal” for her.

“I wrote it about my first love whose presence and absence in my life over the past 8 years has taught me more about myself than he will probably ever know,” she wrote Thursday on her Instagram page. “And I’m endlessly grateful to him for that.”

She thanked Gomez “for her beautiful, honest performance and for believing in the song.” She also thanked her co-writers and producers on the song – Gomez, Parrish Warrington, Diederik van Elsas and Micah Premnath, as well as her parents.

Maine singer-songwriter Amy Allen has co-written the newest single by pop singer Selena Gomez, released Thursday. Allen is seen here with her band, Amy & the Engine, at Urban Farm Fermentory in Portland in 2016. Staff photo by Ben McCann

Growing up in southern Maine, Allen graduated in 2010 from Waynflete School in Portland, where she was a two-sport star in  lacrosse and  cross country. She lived in Windham and South Portland, recording her music as a teenager and performing around Portland for several years and graduated from the Berklee College of Music in Boston. In recent years she was the lead singer and guitar player in the Boston-based band Amy & The Engine.

Allen, now 26, has said that she began to think more seriously about writing songs for other people after taking a class at Berklee with Kara DioGuardi, a former “American Idol” judge and pop songwriter who lives in York. DioGuardi has written or co-written songs for Gwen Stefani, Britney Spears, Kelly Clarkson and Christina Aguilera, among many others.

DioGuardi said in an email Thursday that Allen’s talent for songwriting was already apparent while she was studying at Berklee.

“In order to get into my class you have to audition. We mostly accept students in their last year as they are more advanced, but Amy applied as a sophomore and her talent was undeniable,” said DioGuardi. “Even then she had a great sense of how to write emotional songs that were unique but still worked for the pop market.”

Since Gomez announced the new single, there has been speculation that it’s about her former boyfriend, fellow pop star Justin Bieber. The two have had a much publicized on-again, off-again romance.

Gomez became a star among tweens on the Disney Channel show “Wizards of Waverly Place.” As a solo artist she’s had several top 10 singles over the past five years including “Come & Get It,” “The Heart Wants What It Wants” and “Same Old Love.” Last year she had a hit song “It Ain’t Me,” teaming with Kygo, a Norwegian DJ and producer.

Ray Routhier can be contacted at 791-6454 or at:

[email protected]

Twitter: @RayRouthier