A novel efficient trilateration algorithm is presented to estimate the position of a target object, such as a mobile robot, in a 2D or 3D space. The proposed algorithm is derived from a nonlinear least-squares formulation, and provides an optimal position estimate from a number (greater than or equal to the dimension of the environment) of reference points and corresponding distance measurements. Using standard linear algebra techniques, the proposed algorithm has low computational complexity and high operational robustness. Error analysis has been conducted through simulations on representative examples. The results show that the proposed algorithm has lower systematic error and uncertainty in position estimation when dealing with erroneous inputs, compared with representative closed-form methods.