Investors were caught off guard by the sudden U.S. assault on technology giants last week, but behind the scenes, the industry's biggest companies have been preparing for this moment of reckoning for months.

They have hired lawyers and built up their lobbying shops in response to antitrust investigations that have been well underway in the European Union, and which are just now getting started in Washington.

People close to the companies said they have long anticipated U.S. probes. And while these tech giants will need to bolster their defenses for added scrutiny closer to home, Amazon.com, Alphabet's Google, Apple and Facebook all have been working publicly and behind the scenes for months to make their cases for why they help competition, rather than harm it, and already have formidable teams in place.

As news of the federal and congressional investigations roiled the companies' shares this week, lawyers and executives working for Amazon, Facebook and Google were taking a wait-and-see approach, according to people familiar with the situation. Google hasn't discussed with the Justice Department, which is set to investigate the company, details about what antitrust officials will focus on, one of the people said.

The search giant, for its part, has in the past faced intense antitrust challenges in the U.S. and elsewhere, and already has a playbook for dealing with them.

The government agencies themselves haven't said what they intend to look at, and actual inquiries may not materialize.

Still, the move toward formal investigations, coupled with a new effort from lawmakers on the House Judiciary Committee to look at antitrust violations by the tech giants, is a clear escalation from the political rhetoric of the past year, led by U.S. President Donald Trump.

"Trump's pretty clearly made some comments about this," said Rob Atkinson, president of the Information Technology & Innovation Foundation, a think tank that lobbies against excessive tech regulation. "Over the next 18 months you're going to see FTC and DOJ certainly be making a lot more noise."

The action of dividing up jurisdiction itself shows the agencies are serious about investigating the companies in a real way, Atkinson said, and shows that criticism of the tech giants has filtered down to the policy level at agencies like the FTC and Justice Department.

The companies have been staffing their in-house legal teams with numerous antitrust lawyers who served in government. Amazon last year hired Bryson Bachman, a former counsel to Makan Delrahim, the head of the DOJ's antitrust division. The former head of the division's San Francisco office, Kate Patchen, left for Facebook last year.

Google has long had a deep bench on antitrust. In-house lawyers include Rob Mahini, who came from the FTC in 2012, and Stewart Jeffries, who was an antitrust counsel for the House Judiciary Committee until 2011, giving them ample time to hone their arguments in favor of the internet giant's business model.

They have also been stepping up spending in Washington. Google, Amazon and Facebook set company records for lobbying spending in 2018 as scrutiny of Big Tech intensified, according to Senate disclosures.

Industry trade groups are another line of defense. As calls spread for tougher scrutiny of the industry, the Computer & Communications Industry Association, whose members include Google, Amazon and Facebook, hosted conferences on antitrust enforcement, and the organization publishes a regular newsletter promoting the industry's view on competition.

Amazon has worked mostly behind the scenes in an effort to contain the antitrust conversation, according to two people familiar with the matter. Amazon representatives visit lawmakers individually, often bringing small-business owners from that legislator's state or district to speak about how Amazon is helping them grow. Last week at a company conference in Las Vegas, Amazon's retail chief disputed the idea that it unfairly competes with independent merchants by pointing out that its business selling private-label goods is much smaller than those of major rivals.

Google and Facebook have also said that they help small businesses compete. In public conference calls and marketing materials, executives from the two firms routinely explain how their products are affordable tools meant to help mom-and-pops find and advertise to a broad range of people.