The ruling is a watershed moment in Brazilian history—and one that could further upend relations with the United States.