Let P --> M be a principal G-bundle. We construct well-defined analogs of Lebesgue measure on the space A of connections on P and Haar measure on the group G of gauge transformations. More precisely, we define algebras of 'cylinder functions' on the spaces A, G, and A/G, and define generalized measures on these spaces as continuous linear functionals on the corresponding algebras. Borrowing some ideas from lattice gauge theory, we characterize generalized measures on A, G, and A/G in terms of graphs embedded in M. We use this characterization to construct generalized measures on A and G when G is compact. The 'uniform' generalized measure on A is invariant under the group of automorphisms of P. It projects down to the generalized measure on A/G considered by Ashtekar and Lewandowski in the case G = SU(n). The 'generalized Haar measure' on G is right- and left-invariant as well as Aut(P)-invariant. We show that averaging any generalized measure on A against generalized Haar measure gives a G-invariant generalized measure on A.