In fact, he never said "the end justify means" , but he refers to it in his book "The Prince". He used to say "For although the act condemns the doer, the end may justify him".
He implied that "the means" matter, and "the end " don't always justiy them. Nevertheless, it is worth accepting all the ramifications of "unjustifiable means".