Is there a word or phrase to express the concept of an action having the opposite effect of the expected outcome?

For example, a drug taken to cure headaches that actually causes headaches, or an advertising campaign designed to deter smoking that leads to an increase in smoking.