The ruling comes after months of back and forth between the Trump administration and the National Trust for Historic Preservation.