The mayor of a New Jersey town said he was racially profiled at JFK Airport this August while he and his family were returning to the US from a trip to Turkey, reports said Friday.

Mohamed Khairullah, a Muslim and the longtime mayor of Prospect Park, said US Customs and Border Patrol agents pulled him aside and detained him for hours when his flight touched down at JFK on Aug. 2, the Bergen County Record reported.

The agents then grilled him about personal details, such as what he studied in college, his mother’s name and where he traveled.

They also asked if he was in contact with any terrorist cells during his trip and if he personally met with any terrorists, according to the report.

“It’s flat-out insulting,” Khairullah told the newspaper. “It’s flat-out stereotyping of Muslims and Arabs.”

Khairullah said the agents then asked for his phone — which contained private emails and other messages — and he voluntarily turned it over to them, according to the report.

He then asked for it back, but they told him they needed to keep it.

The agency held it for 12 days — until a lawyer for the Council on American-Islamic Relations helped get it returned to him, the Record reported.

“I am very familiar with our laws and Constitution, and everything that was going on there was a violation,” Khairullah told the Record on Friday.

“It’s your constitutional right as an American not to have to share information private to you,” Khairullah told the newspaper.

“If you unlock your device, you are sharing everything you have on that device — every email, text message, What’sApp message, every phone call ever made,” he added.

The CBP did not immediately respond to request for comment.