BISMARCK, N.D. (AP) — The North Dakota Supreme Court has ruled that thousands of documents related to security during the construction of the heavily protested Dakota Access Pipeline are public and subject to the state’s open records law.

But the court in its ruling Thursday gave pipeline developer Energy Transfer an opportunity to make a case with state regulators that some of the records are privileged company documents that should remain private.

The decision ends a convoluted dispute over 16,000 documents that has dragged on more than a year and involved multiple entangled lawsuits.