Sunan Abi Dawud, Book 43, Hadith 345 (Abu Dawud 5119)

Narrated Abdullah ibn Mas'ud:

If anyone helps his people in an unrighteous cause, he is like a camel which falls into a well and is pulled out by its tail.