Most stars become white dwarfs after they have exhausted their nuclear fuel (the Sun will be one such). Between one-quarter and one-half of white dwarfs have elements heavier than helium in their atmospheres1,2, even though these elements ought to sink rapidly into the stellar interiors (unless they are occasionally replenished)3,4,5. The abundance ratios of heavy elements in the atmospheres of white dwarfs are similar to the ratios in rocky bodies in the Solar System6,7. This fact, together with the existence of warm, dusty debris disks8,9,10,11,12,13 surrounding about four per cent of white dwarfs14,15,16, suggests that rocky debris from the planetary systems of white-dwarf progenitors occasionally pollutes the atmospheres of the stars17. The total accreted mass of this debris is sometimes comparable to the mass of large asteroids in the Solar System1. However, rocky, disintegrating bodies around a white dwarf have not yet been observed. Here we report observations of a white dwarf—WD 1145+017—being transited by at least one, and probably several, disintegrating planetesimals, with periods ranging from 4.5 hours to 4.9 hours. The strongest transit signals occur every 4.5 hours and exhibit varying depths (blocking up to 40 per cent of the star’s brightness) and asymmetric profiles, indicative of a small object with a cometary tail of dusty effluent material. The star has a dusty debris disk, and the star’s spectrum shows prominent lines from heavy elements such as magnesium, aluminium, silicon, calcium, iron, and nickel. This system provides further evidence that the pollution of white dwarfs by heavy elements might originate from disrupted rocky bodies such as asteroids and minor planets.