We present a study of the dependence of galaxy clustering on luminosity and stellar mass in the redshift range 2 < z < 3.5 using 3236 galaxies with robust spectroscopic redshifts from the VIMOS Ultra Deep Survey (VUDS), covering a total area of 0.92 deg2. We measured the two-point real-space correlation function wp(rp) for four volume-limited subsamples selected by stellar mass and four volume-limited subsamples selected by MUV absolute magnitude. We find that the scale-dependent clustering amplitude r0 significantly increases with increasing luminosity and stellar mass. For the least luminous galaxies (MUV < −19.0), we measured a correlation length r0 = 2.87 ± 0.22 h−1 Mpc and slope γ = 1.59 ± 0.07, while for the most luminous (MUV < −20.2) r0 = 5.35 ± 0.50 h−1 Mpc and γ = 1.92 ± 0.25. These measurements correspond to a strong relative bias between these two subsamples of Δb∕b* = 0.43. Fitting a five-parameter halo occupation distribution (HOD) model, we find that the most luminous (MUV < −20.2) and massive (M⋆ > 1010 h−1 M⊙) galaxies occupy the most massive dark matter haloes with ⟨Mh⟩ = 1012.30 h−1 M⊙. Similar to the trends observed at lower redshift, the minimum halo mass Mmin depends on the luminosity and stellar mass of galaxies and grows from Mmin = 109.73 h−1 M⊙ to Mmin = 1011.58 h−1 M⊙ from the faintest to the brightest among our galaxy sample, respectively. We find the difference between these halo masses to be much more pronounced than is observed for local galaxies of similar properties. Moreover, at z ~ 3, we observe that the masses at which a halo hosts, on average, one satellite and one central galaxy is M1 ≈ 4Mmin over all luminosity ranges, which is significantly lower than observed at z ~ 0; this indicates that the halo satellite occupation increases with redshift. The luminosity and stellar mass dependence is also reflected in the measurements of the large-scale galaxy bias, which we model as bg,HOD (>L) = 1.92 + 25.36(L/L*)7.01. We conclude our study with measurements of the stellar-to-halo mass ratio (SHMR). We observe a significant model-observation discrepancy for low-mass galaxies, suggesting a higher than expected star formation efficiency of these galaxies.