The Department of Homeland Security created a fake university in Detroit to lure — and arrest — illegal immigrant students and recruiters, according to newly unsealed court documents.

The University of Farmington existed in Farmington Hills, Michigan — but had no real teachers, curriculum or actual classes.

Instead, undercover Homeland Security agents posed as “owners and employees” of the school as “part of a federal law enforcement undercover operation designed to identify recruiters and entities engaged in immigration fraud,” according to a federal indictment filed Jan. 15 but unsealed Wednesday.

Prosecutors said the university was used by foreign citizens as a “pay to stay” scheme — which allowed people to stay in the US illegally by claiming to be full-time students.

The indictment charges eight recruiters between the ages of 26 and 35 with conspiracy to commit visa fraud for allegedly helping at least 600 people stay in the country illegally. Prospective students forked over a quarter of a million dollars in total, prosecutors allege.

Most of the recruiters and students originated from India, prosecutors said.

The fake students who were “enrolled” at Farmington “knew that they would not attend any actual classes, earn credits or make academic progress toward an actual degree in a particular field of study,” court papers said.

“Rather, their intent was to fraudulently maintain their student visa status and to obtain work authorization” under a student visa program called Curricular Practical Training, the indictment said.

Agents even maintained social media for the university and created a realistic website with stock photos showing a diverse student body.

The site says the school “traces its lineage back to the early 1950s, when returning soldiers from the Second World War were seeking a quality and marketable education.”

The school is also touted as a “nationally accredited business and STEM institution located in Metro Detroit.”

The recruiters were unaware that the university was a sham — but the purported students knew the visa program was fake, the indictment said.

Dozens of Farmington “students” were also swept up across the nation and arrested by feds on Wednesday.

They were charged with immigration violations and face possible deportation, a US Immigration and Customs Enforcement spokesman told the Detroit News.