State estimation (SE) helps to determine the most-likely steady-state operation of microgrids based on field measurements. It is a fundamental data processing tool responsible for supporting and increasing system visibility and filtering errors that may appear in real-time measurements, system topology, and parameters. Hence, it serves as a reliable basis for the energy management system (EMS) infrastructure. Existing SE methods are based on Newton-like algorithms rather than using specific optimization. Nevertheless, SE can always be reduced to a constrained optimization problem, with the objective of minimizing a given criterion, e.g., weighted least squares (WLS) or weighted least absolute value (WLAV). In this context, this paper presents two unbalanced three-phase AC SE methods based on mathematical programming for microgrids. The effectiveness and validity of the proposed state estimation approach are demonstrated on a real microgrid located at the State University of Campinas, in Brazil, and over one widely known IEEE test system. The method can be easily adapted to other microgrids with different configurations, distributed energy resources, and measurements. Results show that the proposed methods report high accuracy, but the state estimator based on WLS is faster than the WLAV.