-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 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 plugins, 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, 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.Including the direct Higgs searches, we find M H = 116.4 +18.3 −1.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 Z ) = 0.1193 +0.0028 −0.0027 (exp) ± 0.0001(theo). Finally, for the mass of the top quark, excluding the direct measurements, we find m t = 178.2 +9.8 −4.2 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 ± < 780 GeV is excluded for tanβ = 70.