The Obama administration announced Thursday it will phase out its use of some private prisons, affecting thousands of federal inmates and immediately sending shares of the two publicly traded prison operators plunging.

In a memo to the Bureau of Prisons, Deputy Attorney General Sally Yates told it to start reducing "and ultimately ending" the Justice Department's use of private prisons. The announcement follows a recent Justice Department audit that found that the private facilities have more safety and security problems than government-run ones.

The Obama administration says the declining federal prison population justifies the decision to eventually close privately run prisons. The federal prison population — now at 193,299 — has been dropping due to changes in federal sentencing policies over the past three years. Private prisons hold about 22,100 of these inmates, or 12 percent of the total population, the Justice Department said.

The policy change does not cover private prisons used by Immigration and Customs Enforcement, which hold up to 34,000 immigrants awaiting deportation.

"Private prisons served an important role during a difficult period, but time has shown that they compare poorly to our own Bureau facilities," Yates wrote in a memo to the acting director of the Federal Bureau of Prisons. As private prison contracts come to an end, the bureau is not to renew the contract or it should at least "substantially" reduce its scope, Yates wrote. She did not specify a timeline for when all federal inmates would be in government-owned facilities.

Democratic presidential candidate Hillary Clinton says the country should move away from using private facilities to house inmates. The Clinton campaign has said it no longer accepts contributions from private prison interests, and if it receives such a contribution, it will donate that money to charity. The private prison industry is a major contributor to Republican political campaigns, particularly in recent years. GOP presidential candidate Donald Trump has said he supports the use of private prisons.

The private prisons on the chopping block are operated by three private companies — Corrections Corporation of America, GEO Group Inc., and Management and Training Corporation. After the announcement Thursday, Corrections Corp. stock dropped $13.22, or 48.6 percent, to $14 and Geo Group tumbled $13.80, or 42.7 percent, to $18.49. Both companies get about half their revenue from the federal government.

The Management and Training Corporation and Corrections Corporation of American issued statements saying they were disappointed with the decision. They also said they disagreed with the conclusions of an inspector general's audit that preceded the Justice Department's decision.

The federal government started to rely on private prisons in the late 1990s due to overcrowding. Many of the federal prison inmates held in private facilities are foreign nationals who are being held on immigration offenses, the audit said.

Immigration and human rights advocates have long-complained about the conditions in privately-run prisons. Amnesty International, on Thursday, urged states to follow suit. Some states, such as Kentucky, already have.

Before Thursday, the Bureau of Prisons had been working toward the goal of phasing out private prison contracts when, three weeks ago, it did not renew a contract for 1,200 beds, Yates said. Thursday's policy change also included direction to change a current solicitation for a private prison contract, cutting the maximum number of beds required by 66 percent.