Linear defects are important pinning sites for vortices in high-temperature superconductors. In YBa 2 Cu 3 O 7Ϫ␦ thin films, the linear defects responsible for high critical currents are threading dislocations formed near the substrate interface. Investigating the first stages of growth of pulsed-lased-deposited YBa 2 Cu 3 O 7Ϫ␦ on single terminated ͑100͒ SrTiO 3 substrates, we study the genesis of these dislocations. We find that the formation of linear defects occurs above a certain critical layer thickness at which a coherent growth transition takes place. Coherent islands are formed, surrounded by highly strained trenches. These trenches facilitate the formation of dislocation half-loops. Such half-loops relieve the misfit strain and form misfit and threading dislocations. The number of threading dislocations thus depends on the island density. This model explains both the short-range lateral order of the threading dislocations and their decreasing density at elevated substrate temperatures.