Boeing and General Dynamics finally have reached an agreement in the longstanding dispute over the cancellation of the U.S. Navy’s A-12 Avenger stealth aircraft program.

The nearly $400 million agreement would bring the case to an end in exchange for in-kind payments from the companies to the Navy. The three parties will ask the U.S. Court of Federal Claims to dismiss the case, according to the Justice Department.

Under the settlement agreement, General Dynamics will provide $198 million in credits to the Navy toward the design, construction and delivery portions of the DDG-1000 destroyer program, according to the company’s third-quarter 2013 earnings statement.

“We are closing a 23-year-long chapter in the annals of naval aviation and further strengthening, through the contractors’ in-kind payment, the Navy’s capabilities and capacities,” said Secretary of the Navy Ray Mabus. “The litigation was protracted and difficult, but it saved the Navy billions of dollars. We thank the Justice Department for its superb representation over these many years.”

The agreement was contingent upon Congress providing authorization for the deal. That was provided by the fiscal 2014 National Defense Authorization Act passed by lawmakers late last year.

The A-12 case is one of the largest and longest-running military procurement disputes. In 1991, then-Defense Secretary Dick Cheney canceled the $4.8 billion stealth attack aircraft, run by General Dynamics and McDonnell Douglas, which has since been acquired by Boeing, in part due to the government’s conclusion that contractors were not meeting cost and schedule targets. The Navy demanded that contractors repay $1.33 billion to the government.

The prime contractors sued the government, arguing that they were due penalty payments because the contract was canceled for “convenience,” not a failure to perform, and the court case has festered in federal dockets. In 2011, the Supreme Court weighed some secrecy and contracting elements of the litigation and sent it back to lower courts.