The global fit of the Standard Model to electroweak precision data, routinely performed by the LEP electroweak working group and others, demonstrated impressively the predictive power of electroweak unification and quantum loop corrections. We have revisited this fit in view of (i) the development of the new generic fitting package, Gfitter, allowing for flexible and efficient model testing in high-energy physics, (ii) the insertion of constraints from direct Higgs searches at LEP and the Tevatron, and (iii) a more thorough statistical interpretation of the results. Gfitter is a modular fitting toolkit, which features predictive theoretical models as independent plug-ins, and a statistical analysis of the fit results using toy Monte Carlo techniques. The state-of-the-art electroweak Standard Model is fully implemented, as well as generic extensions to it. Theoretical uncertainties are explicitly included in the fit through scale parameters varying within given error ranges. This paper introduces the Gfitter project, and presents state-of-the-art results for the global electroweak fit in the Standard Model (SM), and for a model with an extended Higgs sector (2HDM). Numerical and graphical results for fits with and without including the constraints from the direct Higgs searches at LEP and Tevatron are given. Perspectives for future colliders are analysed and discussed. In the SM fit including the direct Higgs searches, we find M H =116.4 −1.3 +18.3 GeV, and the 2σ and 3σ allowed regions [114,145] GeV and [[113,168] and [180,225]] GeV, respectively. For the strong coupling strength at fourth perturbative order we obtain α S (M 2 )=0.1193 −0.0027 +0.0028 (exp )±0.0001 (theo). Finally, for the mass of the top quark, excluding the direct measurements, we find m t =178.2 −4.2 +9.8 GeV. In the 2HDM we exclude a charged-Higgs mass below 240 GeV at 95% confidence level. This limit increases towards larger tan β, e.g., $M_{H^{\pm}}<780 \mbox{GeV}$ is excluded for tan β=70.