MT2DInvMatlab is an open-source MATLAB software package for two-dimensional (2D) inversion of magnetotelluric (MT) data; it is written in mixed languages of MATLAB and FORTRAN. MT2DInvMatlab uses the finite element method (FEM) to compute 2D MT model responses, and smoothness-constrained least-squares inversion with a spatially variable regularization parameter algorithm to stabilize the inversion process and provide a high-resolution optimal earth model. It is also able to include terrain effects in inversion by incorporating topography into a forward model. This program runs under the MATLAB environment so that users can utilize the existing general interface of MATLAB, while some specific functions are written in FORTRAN 90 to speed up computation and reuse pre-existing FORTRAN code in the MATLAB environment with minimal modification. This program has been tested using synthetic models, including one with variable topography, and on field data. The results were assessed by comparing inverse models obtained with MT2DInvMatlab and with a non-linear conjugate gradient (NLCG) algorithm. In both tests the new inversion software reconstructs the subsurface resistivity structure very closely and provides an improvement in both resolution and stability. & 2009 Elsevier Ltd. All rights reserved.