BEIJING, May 18 (Reuters) - China dropped its anti-dumping probe into imports of U.S. sorghum on Friday, beating a hasty retreat from a dispute that wreaked chaos across the global grain market and raised concerns about rising costs and financial damage at home.

The move was seen as a goodwill concession as Chinese Vice Premier Liu He was in Washington for talks aimed at resolving trade tensions between the world's two largest economies.

China's Commerce Ministry said in a statement the investigation into a critical ingredient for animal feed and liquor had revealed that anti-dumping and anti-subsidies penalties would inflate living costs for Chinese consumers.

The investigation launched in early February had quickly showed its top trading partner how much financial pain it could inflict on U.S. farmers, analysts said. Last month, Beijing also imposed hefty anti-dumping deposits on imports of the grain.

"China has taught a lesson to the United States and showed how it can hurt U.S. exports," said Ole Houe, director of advisory services at brokerage IKON Commodities in Sydney.

"Now they are showing goodwill by halting its anti-dumping investigation into sorghum imports, but it is a cheap way of showing goodwill as the U.S. does not have much sorghum left to export. The next U.S. sorghum crop will be harvested in August."

Agricultural products are considered one of the most powerful weapons in Beijing's arsenal because a strike against farm exports to China would hurt mostly states that backed U.S. President Donald Trump.

The United States accounts for more than 90 percent of total sorghum shipments to China, with imports from the U.S. worth just over $1 billion last year.

The deposit scheme brought trade to a halt and disrupted supply chains worldwide, with almost two dozen ships carrying U.S. sorghum stranded at sea, as merchants and buyers scrambled to sell cargoes at big discounts elsewhere.

Frantic Chinese importers, who faced crippling extra costs to doing business, had lobbied the government to rethink the plan.

The probe had sparked worries that tariff-inflated costs for the grain would be passed onto feedmakers and eventually push retail meat prices higher.

Corn, soybean and soymeal futures fell on the news as worries over feedmakers having to find alternative ingredients eased.

The ministry said it would return the deposits it had collected. The news brought some unexpected relief to Chinese buyers who still had cargoes stuck at ports.

"This is great news! We are now saved," said a private sorghum trader who had over 600 tonnes of U.S. sorghum stranded at a Chinese port. "We will clear our goods immediately today."

The United States shipped 4.76 million tonnes of sorghum to China in 2017, worth around $1.1 billion and making up the bulk of China's roughly 5 million tonnes of imports of the grain last year, according to Chinese customs data.

Still, some traders said the ending of the sorghum probe may not be enough to entice them back to doing business with the United States while trade tensions remain high. Beijing still threatens to slap aggressive 25 percent tariffs on a swathe of U.S. farm goods, including sorghum and soybeans.

For many, the damage has already been done. Archer Daniels Midland warned earlier this month it will take a $30 million hit to trading profit due to the dispute.

"The damage has been done, and mainly to the domestic buyer," said Cherry Zhang, analyst at Shanghai JC Intelligence Co Ltd.

"The government won't compensate you for the losses out of reselling and demurrage." (Reporting by Tony Munroe, Josephine Mason and Hallie Gu in BEIJING; Additional reporting by Naveen Thukral in SINGAPORE; Editing by Tom Hogue)