This paper is concerned with the existence of solutions to the quasilinear subelliptic Dirichlet problem \(\begin{aligned} -\triangle _{p,X}u=|u|^{p_{Q}^*-2}u+g(x,u)~~\text{ in }~~\Omega ,\quad u\ge 0,~~u\in W_{X,0}^{1,p}(\Omega ), \end{aligned}\) where \(\Omega \) is a bounded open domain of \(\mathbb {R}^n\) , \(\triangle _{p,X}\) denotes the p-sub-Laplacian associated with smooth Baouendi–Grushin-type vector fields, \(p_{Q}^{*}=\frac{pQ}{Q-p}\) is the critical Sobolev exponent, and g(x, u) is a subcritical perturbation. By applying variational methods, we prove the existence of a nontrivial non-negative solution. Furthermore, for the particular case \(g(x,u)=\lambda |u|^{q-2}u\) , we establish the existence of a positive solution.