President Trump may be pressing for a massive withdrawal of U.S. troops from Afghanistan, but it appears American involvement in the country will last. As the U.S. military prepares to draw back in the country, another agency in the Trump administration is stepping in, The Daily Beast has learned. And Trump ally Erik Prince is positioning himself to join in this next phase, Afghan officials say.

The U.S. Geological Survey—a scientific agency in the administration—signed a letter of intent with the Afghan government to help the country unlock what estimates say is nearly $1 trillion in natural resource wealth, according to Afghan officials and two other consultants working with the Ministry of Mines and Petroleum. The two parties signed the paperwork earlier this year.

The U.S. agency has long partnered with Kabul on mining development. By one report, the U.S. has spent hundreds of millions of dollars propping up the mining sector since 2009.

This time, though, USGS is working with the Afghan government to not only help with surveying the mining fields, but also to find ways to sell mining products on the international market. In other words, the U.S. will have a front-seat view as the Afghan government plans the development of its extractive sector. (The Afghan government also works closely with the Russian and Chinese governments on mining.)

The agency could not be reached for comment about this story. But a post on the USAID Facebook page acknowledged the signing of the letter of intent and said the U.S. Geological Survey would also train ministry staffers.

The partnership comes at a time when the demand for Aghanistan's rare minerals is soaring, especially from regions like the central province of Ghazni. There, underneath the cracked earth and in between the crevices of Karkush—a mountain in the infamous Hindu Kush range—lies what international studies say could be the world’s largest reserve of the mineral lithium.

Lithium powers batteries and military devices such as rockets and even nuclear weapons. And the prospect of its riches has international investors and mining companies in a tizzy over how to get their hands on it. That includes a company headed by Prince, the founder of the Blackwater private security company who has made no secret of his desire to replace U.S. troops in Afghanistan with guns-for-hire.

After all, getting lithium out from under the ground and to market in a place like Afghanistan is a laborious and often dangerous task.

The 17-year-long war has made it nearly impossible for international companies to operate in the country. Diplomatic tensions between neighboring countries, and ongoing government corruption, have complicated the process of transporting minerals out of the country. That process is set to become even more difficult, local officials told The Daily Beast, as U.S. troops are set to withdraw in the next 18 months, according to Taliban documents handed over to Reuters.

The Taliban and the U.S., led by special envoy Zalmay Khalilzad, have engaged in peace talks since September. The Taliban had publicly requested that any deal that they agreed to include the complete withdrawal of U.S. troops. The U.S., in turn, wanted the group to pledge to ban foreign terrorist groups from using Afghanistan as a haven for carrying out attacks internationally. There’s been no final deal announced yet. But Khalilzad tweeted that the talks in Doha were “successful,” while at the same time hinting that several other issues needed to be worked out.

Any deal that involves the total withdrawal of U.S. troops could have significant consequences on Afghanistan’s ability to profit off its own resource wealth, officials and contractors on the ground say.

“Security is one of our biggest problems,” said Nargis Nehan, the Afghan minister of mining and petroleum. “We’ve already had to ask the companies to take responsibility for their own security. We just don’t have good experience with protecting them and the mining fields.”

And with the demand to up its security comes more pressure for Nehan to reform the mining sector, which has been plagued by pay-for-play ploys and legal tangles with international companies.

“Afghanistan is ranked one of the most corrupt countries in the world,” she said. “And in the past there has been a severe lack of transparency and a lack of experience in this ministry. The sector became a source of disappointment.”

That’s part of the reason USGS is stepping in . The new partnership will help Afghanistan get a better handle on the geographics and seismics of its land. But it will also instill a sense of accountability and help with the ministry’s reform, Nehan said.

Consultants working with the Afghan government told The Daily Beast that the government is still a while off from finding a solid way of not only reforming the mining sector entirely, but also getting the product out of the country to sell on to international market.

Still, they said, that has not prevented big time businesses from taking meetings with Nehan’s ministry to explore opportunities for future contracts. American companies have signed contracts for gold and copper in the past several months, but China continues to dominate the market in Afghanistan.

Last year, news broke that Prince had pitched the Trump administration on the benefits of investing in Afghanistan’s mining sector to help fund the war. The presentation, obtained by BuzzFeed, specifically mentions lithium and other “rare earth metals.”

Two sources with direct knowledge of the meetings said representatives from Prince’s company, Frontier Services Group, met several times with officials in Afghanistan about opportunities in the Afghan mining sector. Another source said the representatives were particularly interested in lithium. Reached by phone, Prince said Frontier Services Group had not submitted an official bid. And it does not appear that his company has any active interests in the Afghan mining industry to date. Nehan said the ministry has not issued a contract to Frontier Services Group.

The New York Times reported that Prince was in Afghanistan over the summer meeting with government officials and pitching his plan on how contractors could help patch up the space that will ultimately open after U.S. troops leave the country. However, President Ashraf Ghani has apparently vehemently opposed plans to bring outside contractors into the country.

“Our position is very clear,” Nehan said about Prince’s proposed plan for mining. “They can submit a proposal to us and there is a mining law they have to follow. If their request deals with restricted mining it has to go through the national security council.” Afghanistan defines lithium as a restricted mineral.

As part of its agreement with Afghanistan, USGS will help create new maps for restricted mining areas, local officials and contractors said, giving American companies access to up-to-date information on the reserves.

Earlier this year, Centar Ltd., an American company, signed two contracts with Nehan’s ministry to develop sites with possible gold and copper deposits. Ian Hannam, the founder of the company, signed the deal in Washington in October. Hannam, the former global chairman of equity capital markets at J.P. Morgan, was previously embroiled in a scandal over an oil deal in Iraqi Kurdistan.

Meanwhile, the Afghan Public Protection Forces are working for companies already in country to help secure their sites. But Nehan said the worsening security situation, and the introduction of terrorist elements such as the Islamic State group, is putting strain on forces who also work part time securing other government infrastructure projects from the Taliban.