PHOENIX — In a strongly worded critique of the country’s best-known sheriff, the Justice Department on Thursday accused Sheriff Joe Arpaio of engaging in “unconstitutional policing” by unfairly targeting Latinos for detention and arrest and retaliating against those who complain.

After an investigation that lasted more than three years, the civil rights division of the Justice Department said in a 22-page report that the Maricopa County Sheriff’s Office, which Mr. Arpaio leads, had “a pervasive culture of discriminatory bias against Latinos” that “reaches the highest levels of the agency.” The department interfered with the inquiry, the government said, prompting a lawsuit that eventually led Sheriff Arpaio and his deputies to cooperate.

“We have peeled the onion to its core,” said Thomas E. Perez, the assistant attorney general for civil rights, noting during a conference call with reporters on Thursday morning that more than 400 inmates, deputies and others had been interviewed as part of the review, including Sheriff Arpaio and his command staff. Mr. Perez said the inquiry, which included jail visits and reviews of thousands of pages of internal documents, raised the question of whether Latinos were receiving “second-class policing services” in Maricopa County.

Mr. Perez said he hoped Sheriff Arpaio would cooperate with the federal government in turning the department around. Should he refuse to enter into a court-approved settlement agreement, Mr. Perez said, the government will file a lawsuit and the department could lose millions of dollars in federal money.