WASHINGTON — The Justice Department is preparing to release roughly 6,000 inmates from federal prisons starting at the end of this month as part of an effort to ease overcrowding and roll back the harsh penalties given to nonviolent drug dealers in the 1980s and ’90s, according to federal law enforcement officials.

About a third of the inmates are undocumented immigrants who will be deported. Because many of them were convicted of significant legal offenses, President Obama is unlikely to be criticized as sharply for their release by those who have objected to past deportations by the administration.

The release will be one of the largest discharges of inmates from federal prisons in American history. It coincides with an intensifying bipartisan effort to ease the mass incarcerations that followed decades of tough sentencing for drug offenses — like dealing crack cocaine — which have taken a particularly harsh toll on minority communities.

“Today’s announcement is nothing short of thrilling because it carries justice,” said Jesselyn McCurdy, a senior legislative counsel at the American Civil Liberties Union. “Far too many people have lost years of their lives to draconian sentencing laws born of the failed drug war. People of color have had to bear the brunt of these misguided and cruel policies. We are overjoyed that some of the people so wronged will get their freedom back.”