Lockheed Martin Corp. bet big Monday that military spending will rev up after years of shrinking budgets, agreeing to buy helicopter maker Sikorsky Aircraft for $9 billion while shedding nonmilitary work.

Lockheed, the world’s largest defense contractor by sales, on Monday said it agreed to acquire Sikorsky from United Technologies Corp., the defense industry’s largest deal in 20 years. The purchase would add the world’s largest military helicopter maker by sales to Lockheed’s combat jet and missile-defense businesses. At the same time, Lockheed said it would divest a similar-size group of government information technology and services businesses.

The decisions are bold strokes for Ms. Hewson, a 30-year company veteran whose cost-cutting and focus on increasing shareholder returns have doubled Lockheed’s share price since she took charge in January 2013. Lockheed said on Monday it plans to continue that tack.

Black Hawk helicopter maker Sikorsky is “right in our core market,” Ms. Hewson said on a conference call. She noted that the deal’s cost after tax gains would be just $7.1 billion.

The Bethesda, Md., company’s stock gained 2% to $205.13 on Monday, helped by a forecast-beating 4.5% increase in its second quarter profit and a brighter outlook for full-year earnings.