Generalized simulated annealing (GSA) is an optimization technique for locating the global optimum, which contains both classical simulated annealing (SA) and fast simulated annealing (FSA) as particular cases. In this paper, GSA was applied to invert gravity data to obtain the geometry of the 2D basement relief. The behaviour of the algorithm and its comparison with the modified particle swarm optimization (PSO) algorithm were studied by simulations with synthetic data. The results obtained from the inversion show that both GSA and PSO inversion schemes give similar results. However, calibrating the GSA algoritm could lead to better results.