Google denied "working with the Chinese military" on Saturday after President Donald Trump publicly criticized the company in an evening message posted on Twitter.

"Google is helping China and their military, but not the U.S.," Trump said. "Terrible!"

Google is helping China and their military, but not the U.S. Terrible! The good news is that they helped Crooked Hillary Clinton, and not Trump....and how did that turn out? — Donald J. Trump (@realDonaldTrump) March 16, 2019

The tech giant responded swiftly.

"We are not working with the Chinese military. We are working with the U.S. government, including the Department of Defense, in many areas including cybersecurity, recruiting and healthcare,” a spokesperson said.

Trump's criticism came just days after Marine Gen. Joseph Dunford, chairman of the Joint Chiefs of Staff, made similar comments in testimony before Congress.

"The work that Google is doing in China is indirectly benefiting the Chinese military," Dunford said during a Senate Armed Services Committee hearing.

"We watch with great concern when industry partners work in China knowing that there is that indirect benefit," he said. "Frankly, 'indirect' may be not a full characterization of the way it really is, it is more of a direct benefit to the Chinese military."

Google has faced external and internal criticism over the censored search engine it developed to comply with the country's information restrictions, which is codenamed "Project Dragonfly."

In December, CEO Sundar Pichai appeared before Congress, where he stated that there were no plans to launch the search engine “right now” but refused to rule it out in the future.

In June, the company said it would not renew a contract to help the U.S. military analyze aerial drone imagery when it expires, as the company sought to defuse internal uproar over the deal.

The defense program, called Project Maven, set off a revolt inside Google, as factions of employees opposed its technology being used in warfare.

During the Senate Armed Services Committee hearing on Thursday, Republican Senator Josh Hawley sharply criticized Google, referring to it as "a supposedly American company."

Tech companies have faced growing scrutiny from Washington and around the world over issues ranging from hate speech and privacy to foreign influence.

As tech companies have taken a more active role in cracking down on disinformation and abuse, they have also come under fire from conservatives for what they see as political bias.

Trump has leveled similar accusations against Google before.