Abstract The properties of an atomic lubricant confined between two approaching surfaces are investigated by molecular dynamics. In the limit of thin interfaces, the lubricant atoms form well defined layers, whose number decreases in discontinuous steps with increasing applied pressure. These transitions occur easily and completely for unpinned lubricant films, while they are sluggish and incomplete in the case of strong pinning. Before the transition, an intermediate phase arises, which facilitates the thinning of the lubricant. Lateral sliding of the surfaces enhances the thinning rate.