An incoming Harvard freshman was denied entry to the United States after arriving in Boston to begin classes at the school, the university said Tuesday.

The student, Ismail Ajjawi, 17, was questioned by immigration officials for hours at Logan International Airport, according to a statement from the student obtained by The Harvard Crimson, the college newspaper.

A university spokesperson, Jason Newton, confirmed to NBC News that the student had been refused entry into the United States.

"The university is working closely with the student’s family and appropriate authorities to resolve this matter so that he can join his classmates in the coming days," he said in a statement.

Download the NBC News app for breaking news and politics

Ajjawi, who is Palestinian and lives in Lebanon, was allegedly asked about his religious practices and to unlock his phone and laptop, according to the statement cited by The Crimson. When an immigration officer returned with his phone and laptop about five hours later, he was questioned about his friends' social media activity, according to the statement.

"After the 5 hours ended, she called me into a room, and she started screaming at me. She said that she found people posting political points of view that oppose the U.S. on my friend[s] list," he wrote, according to the Crimson.

"I responded that I have no business with such posts and that I didn't like, [s]hare or comment on them and told her that I shouldn't be held responsible for what others post," he wrote. "I have no single post on my timeline discussing politics."

Customs and Border Protection told NBC News that Ajjawi was deemed inadmissible to the U.S. "based on information discovered during the CBP inspection."

CBP said it could not release specific information about individual travelers because of privacy act requirements and for law enforcement purposes. If the agency deems someone as inadmissible to the U.S., it has the authority to cancel a person’s visa.

The State Department told NBC News it cannot discuss the details of individual cases as visa records are confidential under law.

Ajjawi, who has returned to Lebanon, said in the statement provided to the Crimson that he was in touch with a lawyer and hopes to resolve the visa issue before classes begin next week.

Last month, Harvard President Lawrence Bacow wrote a letter to Secretary of State Mike Pompeo and Acting Secretary of Homeland Security Kevin McAleenan expressing concerns about students having difficulties obtaining visas, including delays and denials.

"Visa policies mandating increased scrutiny of foreign students and scholars (and sometimes naturalized U.S. citizens) from certain countries contribute substantially to mounting concern," he wrote.