Deputy premier John Barilaro said the NSW government would cancel Exploration Licence 7223, releasing Shenhua from its obligations under the exploration licence.
"The NSW government is committed to making NSW the number one investment destination for mining in Australia, but we need to find a balance, and this decision will deliver certainty to farmers and the Liverpool Plains community, while guaranteeing protection to parcels of land with high value biodiversity," he said.
NSW treasurer Dominic Perrottet said the NSW government was committed to supporting the common sense, responsible development of the state's high-quality coal resources, however, there was also a need to protect prime agricultural land.
"The cancellation of this project will mean that no open cut coal mining can occur in the area," he said.
"Coal will of course continue to be an important part of our economy and is essential to supporting jobs, and the NSW Government continues to support coal exploration in areas where it makes sense."
Barilaro said the agreement included certainty for local landholders and communities with prime agricultural farmland to be preserved through the relinquishment of the Shenhua Watermark development consent and exploration licence, and the prohibition of future coal mining projects there.
It also includes the acquisition of more than 6000 hectares of high biodiversity land to be managed by Local Land Services including the protection of habitat for koalas and other endangered species and the protection of significant Indigenous cultural sites and artefacts.
"From the strategic release of land to support coal exploration in the right areas, to unlocking investment opportunities for high tech metals and critical minerals, mining remains a key priority for the state," Barilaro said.
"The NSW government thanks Shenhua for its cooperation in reaching this agreement."
Lock the Gate Alliance spokeswoman Georgina Woods said the NSW government should be "congratulated for taking this opportunity to end the uncertainty this mine created for the community and protecting this incredibly important area".
"It's a very significant step," she said.
"It's crucial that the government now works with the local community on a process for returning the land owned by Shenhua, including providing ownership of cultural sites to Gomeroi Traditional Owners and facilitating a shift back from mining to farming."
Shenhua and the NSW Minerals Council were approached for comment.