We introduce a homology theory for k-graphs and explore its fundamental properties. We establish connections with algebraic topology by showing that the homology of a k-graph coincides with the homology of its topological realisation as described by Kaliszewski et al. We exhibit combinatorial versions of a number of standard topological constructions, and show that they are compatible, from a homological point of view, with their topological counterparts. We show how to twist the C*-algebra of a k-graph by a T-valued 2-cocycle and demonstrate that examples include all noncommutative tori. In the appendices, we construct a cubical set Q(Λ) from a k-graph Λ and demonstrate that the homology and topological realisation of Λ coincide with those of Q(Λ)as defined by Grandis.