MASPETH, Queens — An immigration agent without a warrant tried to search a Queens elementary school for a student, a spokesperson for the mayor’s office said Saturday.

The immigration agent showed up at P.S. 58 on Thursday asking about a student in 4th grade, Mayoral spokesman Eric Phillips said. The school turned him away.

“As a mother, I am deeply troubled and horrified at this attempt on the part of federal immigration agents to reach any child in our schools,” said Queens Borough President Melinda Katz. “P.S. 58 officials did the right thing by following proper protocols of the city administration, stopping the agents at the door and protecting their students.”

State law entitles students ages 5 to 21 to a free public education, regardless of immigration status.

“All students, regardless of immigration status, deserve a great education in public schools,” New York City’s Schools Chancellor Carmen Fariña previously said.

Officials from the state in February advised schools to call the superintendent and school attorney if faced with an immigration agent.

“All students, regardless of status, welcome in @NYCSchools,” the Office for Immigrant Affairs tweeted. “Fed imm enforcement is not.”