Pollution error is a well known source of inaccuracies in continuous or discontinuous FE approaches to solve the Helmholtz equation. This topic is widely studied in a large number of papers, e.g., (Ihlenburg and Babuska, Comput Math Appl 30(9):9–37, 1995; Ihlenburg, Finite element analysis of acoustic scattering applied mathematical sciences, vol 132. Springer, New York, 1998). Robust methodologies for structured square meshes have been developed in recent years. This work seeks to develop a methodology based on Petrov–Galerkin discontinuous formulation, to minimize phase error for Helmholtz equation for both structured and unstructured meshes. A Petrov–Galerkin finite element formulation is introduced for the Helmholtz problem in two dimensions using polynomial weighting functions. At each node of the triangular mesh, a global basis function for the weighting space is obtained, adding bilinear $$C^0$$ Lagrangian weighting function linear combinations. The optimal weighting functions, with the same support of the corresponding global test functions, are obtained after computing the coefficients of these linear combinations attending to optimal criteria. This is done numerically through a preprocessing technique that is naturally applied to non-uniform and unstructured meshes. In particular, for uniform meshes a quasi optimal interior stencil of the same order of the quasi-stabilized finite element method stencil derived by (Babuska et al., Comput Meth Appl Mech Eng 128:325–359, 1995) is obtained. The numerical results indicate a better performance in relation to the classic discontinuous Galerkin method.