Studies of the atomic and electronic structures of Pd clusters with 2-23, 55 and 147 atoms have been carried out using the ultrasoft pseudopotential plane wave method and the spin-polarized generalized gradient approximation for the exchange-correlation energy. We find predominantly an icosahedral growth in these clusters and size dependent oscillatory magnetic moments that are not confined just to the surface atoms. Atomically closed shell 13-, 55- and 147-atom clusters have large moments of (formula presented) (formula presented) and (formula presented) respectively. But cubic (formula presented) isomer has a low moment of (formula presented) only, indicating the importance of the icosahedral structure in the development of magnetism in Pd clusters. The evolutions of the (formula presented) hybridization, the magnetic moment and the electronic structure are discussed as a function of the cluster size. The magnetic energy is found to be small. Further studies on the adsorption of H and O show that though both an increase as well as a decrease of the moment are possible, often there is a reduction in the magnetic moments of Pd clusters. A hydrogen induced metal to nonmetal transition is predicted in (formula presented) and (formula presented) clusters. {\textcopyright} 2002 The American Physical Society.