Deal with the devil

Meaning: To accept an unpleasant or morally questionable arrangement in order to achieve something.

Example: Some critics accused the company of making a deal with the devil to increase its profits.