  We introduce and analyse a general notion of fundamental group for
noncommutative spaces, described by differential graded algebras. For this we
consider connections on finitely generated projective bimodules over
differential graded algebras and show that the category of flat connections on
such modules forms a Tannakian category. As such this category can be realised
as the category of representations of an affine group scheme $G$, which in the
classical case is (the pro-algebraic completion of) the usual fundamental
group. This motivates us to define $G$ to be the fundamental group of the
noncommutative space under consideration. The needed assumptions on the
differential graded algebra are rather mild and completely natural in the
context of noncommutative differential geometry. We establish the appropriate
functorial properties, homotopy and Morita invariance of this fundamental
group. As an example we find that the fundamental group of the noncommutative
torus can be described as the algebraic hull of the topological group $(\mathbb
Z+\theta \mathbb Z)^2$.
