Microscale variability of phytoplankton has been detected in vertical profiles in the ocean for decades, yet its mechanism of formation remains unclear. Here a mechanism is presented which can generate thin (10s of centimeters) layers of phytoplankton through the interaction of near-inertial wave shear with horizontal (along-isopycnal) patchiness of phytoplankton. Horizontal biomass patches along isopycnals are advected over each other by the vertical shear of near-inertial waves, generating layers in vertical profiles. The thickness of the phytoplankton layers can be much less than the vertical wavelength of the internal wave, due to tilting and stretching of horizontal patches of phytoplankton. The thickness of the layers is directly related to the vertical shear and the along-isopycnal scale of the phytoplankton patches: shorter horizontal scales generate thinner layers for a given shear. The amplitude of the biomass difference between layers is directly proportional to both the along-isopycnal and vertical biomass gradients. The model predicts the thickness, time of occurrence and duration of layers during the internal wave's cycle. This mechanism is likely a ubiquitous feature of the world's ocean, and would be particularly important in regions of strong horizontal gradients of properties.