Repeating something that you heard someone say is the literal definition of hearsay. Typically courts want to hear about facts from people who actually know those facts, not someone who heard someone talking about those facts.
This would fall under the "statement against interest" exception to hearsay, though, because obviously the person who originally said the thing isn't going to want to admit in court that they were committing a crime.
The fact is that he said it.
You aren't repeating a fact you heard him say, you are reporting what you heard him say.