With the goal of confirming the metallicity ``excess'' present in stars with planetary-mass companions, we present in this paper a high-precision spectroscopic study of a sample of dwarfs included in the CORALIE extrasolar planet survey. The targets were chosen according to the basic criteria that 1) they formed part of a limited volume and 2) they did not present the signature of a planetary host companion. A few stars with planets were also observed and analysed; namely, HD 6434, HD 13445 (Gl 86), HD 16141, HD 17051 (iota Hor), HD 19994, HD 22049 (epsilon Eri), HD 28185, HD 38529, HD 52265, HD 190228, HD 210277 and HD 217107. For some of these objects there had been no previous spectroscopic studies. The spectroscopic analysis was done using the same technique as in previous work on the metallicity of stars with planets, thereby permitting a direct comparison of the results. The work described in this paper thus represents the first uniform and unbiased comparison between stars with and without planetary-mass companions in a volume-limited sample. The results show that 1) stars with planets are significantly metal-rich, and 2) that the source of the metallicity is most probably ``primordial''. The results presented here may impose serious constraints on planetary system formation and evolution models. Based on observations collected at the La Silla Observatory, ESO (Chile), with the spectrograph at the Euler Swiss telescope, with the spectrograph at the 1.52-m ESO telescope (Observing run 66.C-0116 B), and using the UES spectrograph at the 4-m William Hershel Telescope (WHT), at La Palma (Canary Islands).