Genetic engineering by viral infection of single cells is useful to study complex systems such as the brain. However, available methods for infecting single cells have drawbacks that limit their applications. Here we describe 'virus stamping', in which viruses are reversibly bound to a delivery vehicle-a functionalized glass pipette tip or magnetic nanoparticles in a pipette-that is brought into physical contact with the target cell on a surface or in tissue, using mechanical or magnetic forces. Different single cells in the same tissue can be infected with different viruses and an individual cell can be simultaneously infected with different viruses. We use rabies, lenti, herpes simplex, and adeno-associated viruses to drive expression of fluorescent markers or a calcium indicator in target cells in cell culture, mouse retina, human brain organoid, and the brains of live mice. Virus stamping provides a versatile solution for targeted single-cell infection of diverse cell types, both in vitro and in vivo.