For the first time in a while, investors are betting big on “big government.”

The federal services market has experienced a jolt of dealmaking activity in recent months as companies position themselves to capture new government spending, breathing life into a sector that has been sluggish for years.

In late January, fast-growing technology contractor ECS Federal was bought for $775 million by On Assignment, a California-based recruiting firm with little experience in the federal market. In the same week, Lockheed Martin spinoff PAE bought the firm Macfadden & Associates in a move that was largely viewed as an effort to consolidate amid shifting budgets.

Meanwhile, Falls Church, Va.-based defense giant General Dynamics upped the ante last week when it announced a $6.8 billion agreement to buy CSRA, one of the largest government IT services firms. Also last week, two private equity firms added to their stable of federal contractors: Veritas Capital is acquiring the government business of PricewaterhouseCoopers; and Arlington Capital Partners is buying a small engineering services firm called Integrity Applications.

Analysts took the flurry of activity as a sign of changing times for the government services sector, which was hit hard by the sequestration-related budget cuts that started in 2013.

“I’m confident 2018 will be the best government contracting [mergers and acquisitions] year since 2012, and will maybe even beat 2012,” said Robert D. Kipps, managing director of the aerospace- and defense-focused investment bank KippsDeSanto. “People are looking through budget volatility as a near-term blip, and right now we’re in a cycle where government contracting is in vogue.”

The deals come at a time when federal spending is once again set to increase, drawing fresh attention from Wall Street and investors.

Two short-lived government shutdowns in late January did not prove as costly for contractors as many had feared, largely because Congress approved a spending plan, one that steered a big increase to the defense industry. The sequestration-related spending caps that have limited defense spending since 2013 have been lifted for the next two years, and the Pentagon’s budget is slated to increase by 13 percent.

That surge has created opportunities for acquisition-minded firms, many of which can take advantage of interest rates that remain at historic lows.

Many are considering “services companies” that supply many of the workers needed to take on new projects, such as efforts to move traditional computer systems off mainframe machines and into the Internet cloud.

The prospect that the government will be able to once again fund modernization efforts has caught the attention of a wide range of companies.

On Assignment’s decision to pay $775 million for ECS Federal was particularly notable in that a commercially oriented company saw a growth opportunity in the federal market, and paid a sizable sum for a seat at the table. On Assignment has built its business around providing skilled IT professionals to corporations, with less than 10 percent of its business coming from the federal government.

Its acquisition of ECS Federal effectively triples On Assignment’s federal revenue and gives it a chance to become a major player in the federal IT services market.

“It’s interesting to see a commercial company buy into the government IT market, because that’s the opposite of what’s been going on over the past few years,” said Byron Callan, a defense-focused investment analyst who is director at Capital Alpha Partners.

General Dynamics’ mammoth deal for CSRA also marked a shift, as close competitors such as Lockheed Martin have largely exited the government services market.

Not all the dealmaking is aimed at competing for bigger budgets. Some acquisitions are defensive. Analysts cite the example of PAE, an Arlington-based government services business that is the single-biggest recipient of federal contract dollars from the State Department, an agency that has been targeted repeatedly for steep budget cuts under President Trump.

On Feb. 2, PAE announced it would spend an amount of money that wasn’t disclosed to buy Macfadden, a disaster relief services firm that works primarily for the U.S. Agency for International Development, another agency that has experienced funding cuts under Trump.

PAE’s executives said Macfadden’s foreign aid work will fit well alongside their company’s work with the State Department.

“Macfadden will expand PAE’s customer reach, building upon the relationship PAE established with USAID when PAE supported their response to the Ebola outbreak in 2015,” PAE chief executive John Heller said in a release. “Macfadden’s specialized capabilities and distinguished service record complements work PAE currently performs especially with the Department of State.”

An earlier version of this story incorrectly transposed the letters in the name of contracting firm CSRA. The story has been updated.