SAN SALVADOR — Lawmakers in El Salvador voted overwhelmingly on Wednesday to prohibit all mining for gold and other metals, making the country the first in the world to impose a nationwide ban on metal mining, environmental activists said.

Declaring that El Salvador’s fragile environment could not sustain metal mining operations, legislators across the political spectrum approved the ban, which had broad support, particularly from the influential Roman Catholic Church.

Supporters said the law was needed to protect the country’s dwindling supply of clean water.

“Today in El Salvador, water won out over gold,” Johnny Wright Sol, a legislator from the center-right Arena party, wrote on Twitter.

The vote in the Legislative Assembly turned a decade-old moratorium on mining into law, halting efforts by international companies to tap the gold belt running across the northern provinces of El Salvador.