An astrometry project on PSR B1257+12, a millisecond pulsar with a planetary system, has been carried out with the Very Long Baseline Array and the European Very Long Baseline Interferometry (VLBI) Network at the central frequencies of 1465 and 1540 MHz, respectively. This project consists of nine epochs of phase-referenced observations spanning about two years. Model-independent estimates of the distance and velocity of this pulsar have been obtained using VLBI astrometry for the first time. The precise distance to PSR B1257+12 is 710-38+43 pc. This is in agreement with the timing results, but is larger than the predictions from dispersion measurements using Galactic electron density distribution models. The measured proper-motion components of PSR B1257+12 in right ascension and declination are 46.44 ± 0.08 and -84.87 ± 0.32 mas yr-1, respectively. The corresponding transverse velocity of PSR B1257+12 is ∼326 km s-1, making it the only millisecond pulsar known so far with a velocity clearly exceeding 300 km s-1. Based on these results, the apparent X-ray efficiency of this pulsar is estimated to be in the same range as other millisecond pulsars, which is not as low as previously thought. The planets around PSR B1257+12 should be formed in a protoplanetary disc. We review possible evolutionary scenarios for the protoplanetary disc, and conclude that the protoplanetary disc of this pulsar has most probably been formed by the evaporation or disruption of its companion in a binary.