WASHINGTON — After providing nearly $26 billion in aid to farmers over the past few years to offset losses from President Trump’s trade war with China, the administration now has another giant new pot of money to pass out to them with little or no oversight, courtesy of the $2 trillion coronavirus stimulus package.

The legislation, given final passage by the House on Friday and quickly signed into law by Mr. Trump, allocates as much as $23.5 billion in assistance for farmers and gives broad leeway to Agriculture Secretary Sonny Perdue to direct it where he sees fit.

The money was inserted into the bill by senators from farm states after an intense lobbying push by major corporate farming groups. Parts of the industry are suffering immediate hits from the coronavirus outbreak, such as corn growers who have seen prices for ethanol plummet and mom-and-pop suppliers of farm markets that have closed in many cities.

But unlike industries such as airlines, hotels and automakers, which have largely or completely shut down, most farms are still operating. And sales of some products in the industry have surged as worried consumers stock up, generating shortages of meat, chicken, eggs and flour.