We give a criterion for a set of n hyperbolic isometries of a CAT(0) metric space X to generate a free group on n generators. This extends a result by Alperin, Farb, and Noskov who proved this for 2 generators under the additional assumption that X is complete and has no fake zero angles. Moreover, when X is locally compact, the group we obtain is also discrete. We then apply these results to Euclidean buildings.