The top administrator at the Santa Monica-Malibu school district’s flagship campus will leave her post at the end of the month.

Eva Mayoral resigned Thursday as Santa Monica High School principal after three years at the helm and 21 total years in the district, SMMUSD spokeswoman Gail Pinsker confirmed.

In a message to the school community, Mayoral said she is moving out of state to be closer to family.

“I can tell you unequivocally that I have never been fonder of any group of students, parents or staff,” she wrote. “It is this love that has made my life joyful, and this decision excruciating. But you are not my only love. My son and his family, all of whom I adore, have reached out in need, and as unfathomable as it is to leave you, I just don’t have it in me to say no.”

Details regarding the process for naming Mayoral’s successor at Samohi were not immediately clear, but Pinsker said district officials will begin conducting a search for her replacement “immediately.”

The shakeup at the local high school comes as SMMUSD searches for a new superintendent following the announcement that Sandra Lyon will have a new job with the Palm Springs Unified School District starting July 1. An interim leader for the district has not yet been announced.

Mayoral, who earned a bachelor’s degree in biology and a master’s in education from UCLA, taught for six years at Fairfax High School in the Los Angeles Unified School District before arriving at Samohi as a science teacher in 1995. During her initial stint there, she served as chair of the chemistry department and led professional development for Advanced Placement teachers.

In 2004 Mayoral became a Samohi house principal, a role she kept until she was named principal of John Adams Middle School in 2010. In late 2012 she was named administrator of the year by the California Music Educators Association for her work with the JAMS music department.

She was responsible for keeping students safe during the deadly June 2013 shooting at Santa Monica College, which is in close proximity to the 16th Street middle school. She has described it as the scariest ordeal of her life.

Mayoral’s tenure at JAMS ended shortly thereafter as she followed many of the graduates to Samohi, where she replaced Laurel Fretz as principal. Fretz had been in charge of the high school for two years.

In her parting message, MAyoral touted the school’s progress on disciplinary issues, Advanced Placement participation and support for educators.

“I have worked hard and long to be sure that we had a critical mass of supporters within everything we have done,” Mayoral wrote. “We have a huge number of brilliant and committed teachers and administrators who will carry on and care for this work.”

Samohi PTSA president Joan Krenik said it’s been a privilege to work with Mayoral.

“Her passion for Samohi and unwavering support of all students has resulted in the implementation of many programs and a change in culture that will benefit our community for years to come,” she said. “Eva will be sorely missed.”

Under Mayoral’s watch, Samohi also saw a variety of crises, controversies and tragedies.

In the fall of 2013, she canceled the school’s homecoming rally following what she deemed disruptive behavior in prior assemblies. She also received pushback over new dress-code emphases in her first few months as principal.

In spring 2014, she was criticized over the handling of a scuffle between a student and teacher Mark Black, who was reportedly trying to confiscate marijuana.

Tensions also flared over another personnel matter in mid-2014, when Vikings baseball coach Kurt Schwengel was canned after two successful seasons. Allegations of cronyism popped up when Loren Drake was named as Schwengel’s replacement.

Mayoral’s leadership was again tested as a measles outbreak spread across Southern California in early 2015, when a Samohi baseball coach and an infant at the school’s child care facility were found with the contagious virus. Around the same time, she was also forced to deal with the aftermath of a brawl between Samohi and Beverly Hills High School students following a league basketball game.

Shock and sadness washed over the campus in May 2015 when freshman Leo Castillo, a JAMS alumnus, was killed while riding his scooter in Santa Monica.