He was able to escape prosecution because of a loophole in the law.

Literal

Law [in-に] loophole [subject-が] exists [because-of-ために], he [topic-は] prosecution [object-を] escape [could-ことができた]

抜け穴 literally 'escape-hole' is used figuratively for a loophole — in laws, rules, arguments, contracts. ために after a clause marks cause ('because of'), distinct from ために after a verb ('in order to'). ~ことができる is the standard formal potential form.