Run afoul of (someone or something)

To get into trouble with someone or something.

The young man ran afoul of the law and got into much trouble.