Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Thousands of veterans who were forced to pay back the millions of dollars in bonuses they’d gotten for reenlisting to fight in Iraq and Afghanistan will get their money back.

The Pentagon announced Tuesday it has set up a process to reimburse or eliminate the debts of some 17,000 members of the California Army National Guard who got the bonuses between 2004 and 2010.

California Army National Guard soldiers watch the arrival of the body of soldier Sean Walsh, who died on Nov. 16 during a combat operation in Afghanistan, at Moffett Federal Airfield in Mountain View, California in 2011. Paul Sakuma / AP file

"The process is in place," said acting Undersecretary of Defense for Personnel and Readiness Peter Levine. "We believe that we can complete all these cases well before the July 1st deadline."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Levine’s announcement came three months after Defense Secretary Ash Carter ordered the Pentagon to stop grabbing-back those bonuses, which were improperly awarded during the Bush Administration when it was struggling to find soldiers willing to fight in two unpopular wars.

Related: DoD Sec. Ash Carter Orders Pentagon to Stop Reclaiming Reenlistment Bonuses

“The error was an error on the part of the government as to whether they were eligible” for the bonuses, Levine said. “They may have been misled as to whether they were eligible.”

The soldiers were then targeted by auditors after federal investigators discovered in 2010 that thousands of those bonuses, as well as student loan payments, were improperly approved.

The next year, Army Master Sgt. Toni Jaffe, the California National Guard's bonus and incentive manager, pleaded guilty to filing $15.2 million in false claims and was sentenced to 30 months in federal prison.

But instead of forgiving the botched bonuses, which were no fault of the soldiers, the California National Guard sicced auditors on the service men and women, arguing that the law demanded it.

It wasn't until California lawmakers began hearing from hard-pressed soldiers that the Pentagon realized what was happening and ordered it stopped.

"We don't give somebody a free education; we give them a free education in exchange for a service commitment and that's ... that's part of the bargain," Levine said. "The cases in California are different for several reasons. One is that many of these service members fulfilled their obligation."