Physical and structural origins of morphotropic phase boundaries (MPBs) in ferroics remain elusive despite decades of study. The leading competing theories employ either low-symmetry bridging phases or adaptive phases with nanoscale textures to describe different subsets of the macroscopic data, while the decisive atomic-scale information has so far been missing. Here we report direct atomically resolved mapping of polarization and structure order parameter fields in a Sm-doped BiFeO 3 system and their evolution as the system approaches a MPB. We further show that both the experimental phase diagram and the observed phase evolution can be explained by taking into account the flexoelectric interaction, which renders the effective domain wall energy negative, thus stabilizing modulated phases in the vicinity of the MPB. Our study highlights the importance of local order-parameter mapping at the atomic scale and establishes a hitherto unobserved physical origin of spatially modulated phases existing in the vicinity of the MPB.