WASHINGTON (AP) — It’s the biggest budget the Pentagon has ever seen: $700 billion. That’s far more in defense spending than America’s two nearest competitors, China and Russia, and will mean the military can foot the bill for thousands more troops, more training, more ships and a lot else.

And next year it would rise to $716 billion. Together, the two-year deal provides what Defense Secretary Jim Mattis says is needed to pull the military out of a slump in combat readiness at a time of renewed focus on the stalemated conflict in Afghanistan and the threat of war on the Korean peninsula.

The budget bill that President Donald Trump signed Friday includes huge spending increases for the military: The Pentagon will get $94 billion more this budget year than last — a 15.5 percent jump. It’s the biggest year-over-year windfall since the budget soared by 26.6 percent, from $345 billion in 2002 to $437 billion the year after, when the nation was fighting in Afghanistan, invading Iraq and expanding national defense after the 9/11 attacks.

The extra money is not targeted at countering a new enemy or a singular threat like al-Qaida extremists or the former Soviet Union. Instead the infusion is being sold as a fix for a broader set of problems, including a deficit of training, a need for more hi-tech missile defenses, and the start of a complete recapitalization of the nuclear weapons arsenal.

Every secretary of defense since 2011, when the Congress passed a law setting firm limits on military and domestic spending, has complained that spending caps set by the Budget Control Act were squeezing the military so hard that the number of ready-to-fight combat units was dwindling. Aging equipment was stacking up, troops were not getting enough training and the uncertain budget outlook was clouding America’s future.

“I cannot overstate the negative impact to our troops and families’ morale from all this budget uncertainty,” Mattis said just hours before the House and Senate approved the deal.

More money for the Pentagon, however, is not the simple solution some might think. Even with the spending caps of recent years, the defense budget has been robust by historical standards. Todd Harrison, a defense budget specialist at the Center for Security and International Studies, says military funding has been near the inflation-adjusted peak levels of the armed forces buildup during the 1980s under President Ronald Reagan.

The problem, Harrison says, is that the budgets have been stretched by rising personnel costs, more expensive technology investments and other factors, compounded by the cumulative effects of more than a decade of combat in Afghanistan, Iraq and elsewhere in the Middle East. And throughout this period, the military has been required to keep up or even increase its pace of operations at home and abroad — and there is no letup in sight.

“We are stretched too thin,” Harrison said Friday. “We are trying to do too much with the size force that we have all around the world. Money doesn’t necessarily fix that.”

The U.S. has far fewer troops in Iraq than it did 10 years ago, and the roughly 15,000 in Afghanistan today compare with a peak of 100,000 in 2010-11, but the trend is leaning in the opposite direction under President Donald Trump, including stepped up counterterrorism operations in Somalia and Yemen. Trump has added several thousand troops in Afghanistan. Also, the prospect of war against North Korea looms large as Trump insists on compelling the North to give up its nuclear weapons.

The enormous increases in defense spending agreed to by lawmakers on Friday go beyond what Trump ask for. Of the $700 million in spending for the 2018 budget year that started last Oct. 1, about $629 billion is for core Pentagon operations and nearly $71 billion is for the wars in Afghanistan and elsewhere.

Trump had requested a 2018 military budget of $603 billion for basic functions and $65 billion for war missions.

The deal Congress approved early Friday also sets the Pentagon’s 2019 budget at $716 billion, giving Mattis the financial stability he’s been demanding.

The biggest winners in the military buildup are the country’s largest defense contractors, such as Lockheed Martin, Boeing and General Dynamics, that spend millions of dollars each year lobbying Congress.

The legislation that Trump signed Friday is expected to translate to billions more for one of the Pentagon’s highest priorities: missile defense. The appropriations committees still need to finalize exactly what will be in the 2018 defense budget. But they’re likely to follow closely the defense policy bill approved by Congress late last year. That included $12.3 billion for the Pentagon’s Missile Defense Agency and ordered a more rapid buildup of the nation’s missile defenses as North Korea has refused to back away from developing nuclear missiles capable of striking the United States.

The policy bill included money for as many as 28 additional Ground-Based Interceptors — anti-missile missiles that would be launched from underground silos in Alaska in the event the U.S. decided to try to shoot down a North Korean missile heading toward the United States. The bill also grants U.S. troops a 2.4 percent pay raise, slightly higher than the Pentagon had proposed.

Before the budget deal was reached, Congress frequently resorted to the use of stopgap spending bills. Under these short-term measures, the Pentagon’s budget was locked at current year’s levels and the military services can be barred from starting new programs or ending old ones. The Pentagon complained that the stopgap approach forced them to shift dollars intended for new weapons and other needed equipment to pay for ongoing operations.