A New Jersey priest says he collected child porn to get revenge on God — because he kept losing at poker.

The Rev. Kevin Gugliotta, formerly parochial vicar of the Holy Spirit Church in Union, N.J., happens to be a nationally-ranked poker player.

According to court records, after his arrest last October on 40 counts of possessing and disseminating child pornography, Gugliotta told probation officers that he’d felt God was attacking him by making him lose poker tournaments and games, the Associated Press reported.

Gugliotta’s defense lawyer, Jim Swetz, confirmed to the AP that revenge against God was the “reason” his client collected porn.

On Thursday, a Pennsylvania judge sentenced Gugliotta to up to two years jail for admittedly disseminating child pornography via the laptop he used at his weekend home in Lehigh Township, Pa.

He gets credit for the ten months he has already served since his arrest and could be freed in as soon as two months.