What does a beer company do to hedge against slowing growth in its main business? In the case of the parent company of Corona, the answer is to invest heavily in the marijuana industry.

Constellation Brands, which also makes Robert Mondavi wine and Svedka vodka, announced Wednesday that it had invested $4 billion in Canopy Growth, a publicly traded Canadian cannabis producer. The deal comes nearly 10 months after Constellation first took a 10 percent stake in Canopy to help create nonalcoholic cannabis-infused drinks and other products.

Constellation’s investment in Canopy, the biggest known deal in the marijuana industry, shows just how far traditional alcoholic beverage companies are willing to go to find growth. As sales of beer fall in the United States, brewers have begun to bet that legalization of marijuana around the globe, especially the United States, will continue to build momentum and sales of cannabis products will take off.

Research firm Euromonitor estimates that the U.S. market for legal marijuana products will reach $20 billion by 2020, up from $5.4 billion in 2015.

While a number of states have legalized the recreational use of marijuana in recent years, purchasing or possessing it remains a federal crime. Constellation said in November that it does not plan to sell cannabis products in the United States while it remains illegal on the federal level.

But as cannabis becomes legal in more countries — in Canada, for example, recreational use will become legal on Oct. 17 — alcoholic beverage companies are trying to buy into the cannabis industry before they become disrupted by it.

How concerned are beer companies? Molson Coors listed legal cannabis among the biggest possible risks to its business in its annual shareholder report earlier this year:

“The emergence of legal cannabis in certain U.S. states and Canada may result in a shift of discretionary income away from our products or a change in consumer preferences away from beer.”

So far Heineken and Molson Coors have moved to sell cannabis-infused drinks. Heineken’s Lagunitas brand has started selling nonalcoholic sparkling water featuring THC, the active component of marijuana. And Molson Coors has formed a joint venture with Hydropothecary, a weed producer, to make cannabis-infused beverages.

Under the terms of Wednesday’s deal, Constellation’s stake in Canopy will increase to 38 percent and Constellation has the right to raise that to 50 percent.

“As the leader in the total beverage alcohol space, we look forward to reaping the benefits of our cannabis investment, which we see as incremental to our core beer, wine and spirits portfolio,” Robert Sands, Constellation’s chief executive, told analysts on a call Wednesday.

But such bold moves still face a number of hurdles. The Justice Department under Attorney General Jeff Sessions has toughened its stance on marijuana-related crimes, making the future of cannabis regulation uncertain.

Michael J. de la Merced is a New York Times writer.