Solutions for many problems of interest exhibit singular behaviors at domain corners or points where boundary condition changes type.
For this type of problems, direct spectral methods with usual polynomial basis functions do not lead to a satisfactory convergence rate.
We develop in this paper a M\"untz-Galerkin method which is based on specially tuned M\"untz polynomials to deal with the singular behaviors of the underlying problems. By exploring the relations between Jacobi polynomials and M\"untz polynomials, we develop efficient implementation procedures for the M\"untz-Galerkin method, and provide optimal error estimates. As examples of applications, we consider the Poisson equation with mixed Dirichlet-Neumann boundary conditions, whose solution behaves like $O(r^{1/2})$ near the singular point, and demonstrate that the M\"untz-Galerkin method greatly improves the rates of convergence of the usual spectral method.