Electron-beam (e-beam) irradiation damage is often regarded as a severe limitation to atomic-scale study of two-dimensional (2D) materials using electron microscopy techniques. However, energy transferred from the e-beam can also provide a way to modify 2D materials via defect engineering when the interaction of the beam with the sample is precisely controlled. In this article, we discuss the atomic geometry, formation mechanism, and properties of several types of structural defects, ranging from zero-dimensional point defects to extended domains, induced by an e-beam in a few representative 2D materials, including graphene, hexagonal boron nitride, transition-metal dichalcogenides, and phosphorene. We show that atomic as well as line defects and even novel nanostructures can be created and manipulated in 2D materials by an e-beam in a controllable manner. Phase transitions can also be induced. The e-beam in a (scanning) transmission electron microscope not only resolves the intrinsic atomic structure of materials with defects, but also provides new opportunities to modify the structure with subnanometer precision.