WASHINGTON — The Justice Department’s Civil Rights Division and the government of Puerto Rico agreed Friday to sweeping changes to the commonwealth’s large and troubled Police Department intended to help overcome a history of discrimination, violence and corruption.

In a 102-page consent decree filed to settle a federal civil rights lawsuit, Justice Department officials and the departing governor of Puerto Rico, Luis G. Fortuño, agreed to far-reaching changes in the way the 17,000-member force recruits, trains, promotes and oversees its officers. This includes strict new policies on the use of force, police interactions with gay and transgender Puerto Ricans, the department’s approach to domestic violence and its handling of civilian complaints. The agreement also reins in the department’s special tactical units, which have drawn much criticism over the years.

Both sides agreed to delay putting the changes in place for several months to give the administration of the incoming governor, Alejandro García Padilla, an opportunity to review and adopt it — or propose changes. The subject is also subject to judicial approval.

“The successful implementation of the reforms contained in this agreement will help to reduce crime, ensure respect for the Constitution and restore public confidence” in the Puerto Rico Police Department, said Thomas E. Perez, the assistant attorney general for civil rights.