  We study synchronization in the two-dimensional lattice of coupled phase
oscillators with random intrinsic frequencies. When the coupling $K$ is larger
than a threshold $K_E$, there is a macroscopic cluster of
frequency-synchronized oscillators. We explain why the macroscopic cluster
disappears at $K_E$. We view the system in terms of vortices, since cluster
boundaries are delineated by the motion of these topological defects. In the
entrained phase ($K>K_E$), vortices move in fixed paths around clusters, while
in the unentrained phase ($K<K_E$), vortices sometimes wander off. These
deviant vortices are responsible for the disappearance of the macroscopic
cluster. The regularity of vortex motion is determined by whether clusters
behave as single effective oscillators. The unentrained phase is also
characterized by time-dependent cluster structure and the presence of chaos.
Thus, the entrainment transition is actually an order-chaos transition. We
present an analytical argument for the scaling $K_E\sim K_L$ for small
lattices, where $K_L$ is the threshold for phase-locking. By also deriving the
scaling $K_L\sim\log N$, we thus show that $K_E\sim\log N$ for small $N$, in
agreement with numerics. In addition, we show how to use the linearized model
to predict where vortices are generated.
