The United States and Brazil have negotiated a settlement to a long-running dispute over cotton subsidies, in a move that heads-off a series of retaliatory measures against American goods.