This article develops distributed synchronous and asynchronous algorithms for the large-scale semidefinite programming with diagonal constraints, which has wide applications in combinatorial optimization, image processing, and community detection. The information of the semidefinite programming is allocated to multiple interconnected agents such that each agent aims to find a solution by communicating to its neighbors. Based on the low-rank property of solutions and the Burer–Monteiro factorization, we transform the original problem into a distributed optimization problem over unit spheres to reduce variable dimensions and ensure positive semidefiniteness without involving semidefinite projections, which are computationally expensive. For the distributed optimization problem, we propose distributed synchronous and asynchronous algorithms, both of which reduce computational burden and storage space compared with existing centralized algorithms. Specifically, the distributed synchronous algorithm almost surely escapes strict saddle points and converges to the set of optimal solutions to the optimization problem. In addition, the proposed distributed asynchronous algorithm allows communication delays and converges to critical points to the optimization problem under mild conditions. By applying the proposed algorithms to image segmentation, we illustrate the efficiency and convergence performance of the two proposed algorithms.