Data association is a fundamental problem in multitarget-multisensor tracking. It entails selecting the most probable association between sensor measurements and target tracks from a very large set of possibilities. With N sensors and n targets in the detection range of each sensor, even with perfect detection there are (n!)N different configurations which renders infeasible a solution by direct computation even in modestly-sized applications. We describe an iterative method for solving the optimal data association problem in a distributed fashion; the work exploits the framework of graphical models, which are a powerful tool for encoding the statistical dependencies of a set of random variables and are widely used in many applications (e.g., computer vision, error-correcting codes). Our basic idea is to treat the measurement assignment for each sensor as a random variable, which is in turn represented as a node in an underlying graph. Neighboring nodes are coupled by the targets visible to both sensors. Thus we transform the data association problem to that of computing the maximum a posteriori (MAP) configuration in a graphical model to which efficient techniques (e.g., the max-product/min-sum algorithm) can be applied. We use a tree-reweighted version of the usual max-product algorithm that either outputs the MAP data association, or acknowledges failure. For acyclic graphs, this message-passing algorithm can solve the data association problem directly and recursively with complexity O((n!)2N). On graphs with cycles, the algorithm may require more iterations to converge, and need not output an unambiguous assignment. However, for the data association problems considered here, the coupling matrices involved in computations are inherently of low rank, and experiments show that the algorithm converges very fast and finds the MAP configurations in this case.