HONG KONG — The Chinese electronics giant Huawei sued the United States government on Wednesday, arguing that it had been unfairly and incorrectly banned as a security threat.

The lawsuit will force the government to make its case against the company more public, but it could also leave Huawei vulnerable to deeper scrutiny of its business practices and relationship with the Chinese government.

The United States has argued that Huawei poses a risk because its equipment could be used by the Chinese authorities to spy on communications and disrupt telecommunications networks. That position has led major wireless carriers in the United States to avoid Huawei’s equipment.

Huawei denies the allegations and says the lawsuit is meant to prove it does not engage in such practices. The company’s plans to file the lawsuit were first reported on Monday by The New York Times.

“The U.S. Congress has repeatedly failed to produce any evidence to support its restrictions on Huawei products,” Guo Ping, Huawei’s rotating chairman, said in a statement announcing the filing of the lawsuit. “We are compelled to take this legal action as a proper and last resort.”

The lawsuit, which was filed in a United States District Court in Plano, Tex., where Huawei has its American headquarters, argues that part of the 2019 National Defense Authorization Act is unconstitutional because it singles out Huawei. The act bans government agencies from contracting with Huawei or companies that use the company’s equipment.

Huawei, China’s biggest maker of telecommunications equipment, has been under pressure for months by the United States authorities. Now, it’s striking back. The suit is part of a markedly aggressive legal and public relations offensive that Huawei has recently mounted to push back against spying accusations.

During a news briefing broadcast on an official Huawei feed on Twitter, Mr. Guo pulled no punches.

“The U.S. government has long branded Huawei as a threat, it has hacked our service and stolen our emails and source code,” he said, referring to National Security Agency documents provided by the former contractor Edward J. Snowden that showed the agency had pried its way into Huawei’s systems.

“Still, the U.S. government is sparing no effort to smear the company and mislead the public about Huawei,” he added. The briefing, streamed on Twitter — an American internet platform blocked in China — reached more than two million people.

In December, Meng Wanzhou, the daughter of Huawei’s founder and the chief financial officer of the company, was detained in Canada at the behest of the United States, which is seeking to extradite her.

Her father, Ren Zhengfei, the company’s founder, has since rejected the claims against his daughter and said that he would wait to see if President Trump would intervene in the case. Ms. Meng has been in court this week in Vancouver, British Columbia, as part of an extradition hearing.

In the meantime, Huawei has battled against many of its customers and nations that have said they would pull back from buying its products. China has also retaliated against Canada by detaining several Canadian citizens. This week, Canadian officials also complained that China had begun to suspend the import of canola from the country.

Lu Kang, the spokesman for China’s Ministry of Foreign Affairs, said on Thursday that the Chinese decision was based on the discovery of pests in Canadian canola.

China has a long history of interrupting trade with other countries in the middle of diplomatic spats. In September 2010, China halted the export of rare earth metals to Japan for two months during a dispute over the sovereignty of a cluster of tiny islands between Japan and Taiwan. Weeks later, China suspended trade talks with Norway and then halted the import of Norwegian salmon after the Nobel Peace Prize was awarded to a Chinese dissident by a Norwegian committee.

Huawei’s lawsuit argues that by singling out the company, Congress has violated constitutional principles on the separation of powers and also the bill of attainder clause, which prohibits legislation that singles out a person or entity for punishment without trial.

“The actual and intended effect of these prohibitions is to bar Huawei from significant segments of the U.S. market for telecommunications equipment and services, thereby inflicting immediate and ongoing economic, competitive, and reputational harms on Huawei,” the company’s lawyers wrote in the suit.

They added that the prohibitions have been carried out without “a fair hearing or the opportunity to rebut the allegations against it, and without opportunity for escape.”

The Russian cybersecurity firm Kaspersky Lab filed, and ultimately lost, a similar legal challenge two years ago. After the Department of Homeland Security directed federal agencies to ban Kaspersky products from their systems, Congress codified the directive into a law.

Kaspersky filed two lawsuits arguing it had been singled out for punishment without a trial. A judge ultimately dismissed the lawsuits, pointing out they came from a legitimate desire to protect American networks.

The Justice Department filed criminal charges against Huawei in January, but those cases focus on the company’s connections to evading American sanctions on Iran and its theft of intellectual property. Neither relates to the core question faced by governments around the world about whether using Huawei’s equipment in new 5G networks causes security concerns.

The new lawsuit seeks to focus on that question, and to push the United States government to make its case. While Huawei is unlikely to reverse American opposition to the company, it may hope to win over government officials in other countries, including some in Europe, who will probably be following the American lawsuit closely.

Debate about the security of Huawei’s systems has come at a critical moment, with countries around the world preparing to spend hundreds of billions of dollars on expanding cellular networks to next generation 5G technology.

The new networks will have faster speeds, but also be used to connect a bewildering number of new sensors and data-collection systems alongside smartphones. That would make vulnerabilities in the networks potentially more serious than with the cellular networks of the past.