Harvard University has agreed to turn over years of confidential applicant and student records to the United States Justice Department, which has opened an aggressive investigation into whether the university has systematically discriminated against Asian-American applicants, officials said Friday.

It was the first time that Harvard had agreed to provide access to records under terms that the Justice Department seemed receptive to. But it added a condition that allowed government lawyers to look at the records only in the offices of Harvard’s lawyers, according to people close to the case.

That condition could make it difficult to do the kind of statistical analysis that the government has said it wants to do. But Harvard has justified it by saying that it wants to protect confidential documents from possibly being leaked to the public.

The Justice Department sought records for thousands of high school students — 160,000 by one estimate — and when Harvard resisted, citing confidentiality, threatened to sue the university if it did not turn over the records by Friday.