We have performed a systematic study on the occurrence of superconductivity in Nb1−xMgxB2 (0.0≤x≤0.40). X-ray diffraction and magnetization measurements are carried out to determine the changes in lattice parameters, superconducting transition temperature (Tc) and critical field (Hc1). The substitution of Mg at Nb site results in considerable stretching of c-parameter with only a slight change in a parameter. Rietveld analysis on X-ray diffraction patterns gives a=3.11 Å and c=3.26 Å for pure NbB2 while a=3.10 Å and c=3.32 Å for Nb0.60Mg0.40B2. This increased c-parameter introduces superconductivity in niobium diboride. Magnetization measurements though indicate the absence of superconductivity in NbB2, the same shows a clear diamagnetic signal at about 10 K for Nb0.60Mg0.40B2 sample. The magnetization M(H) plots exhibit weak superconductivity like hysteresis loops. The stretching of c-parameter from around 3.26 to 3.32 i.e. by 0.06 cannot be explained solely by substitution of Nb by Mg in the lattice. It seems that some Nb deficiencies are introduced in the Nb1−xMgxB2 as Mg is not substituted completely at the vacant Nb sites. This could be seen from XRD results, where one can clearly notice the presence of small amount of MgO in Nb1−xMgxB2 samples.