Definition:Contrary Statements/Linguistic Note

Linguistic Note on Contrary Statements
In the context of contrary statements, the word contrary is pronounced with the stress on the first syllable: con-tra-ry.

There is a different usage of contrary which means, of a person, perversely inclined to disagree or to do the opposite of what is expected or desired. In this context, the stress is on the second syllable: con-tra-ry, making it rhyme, conveniently, with Mary, hence the children's nursery rhyme:
 * Mary, Mary, quite contrary
 * How does your garden grow?
 * With silver bells and cockle shells
 * And pretty maids all in a row.

which, it has been suggested, may have been written as a social satire on the reign of either of the 17th-century queens in Britain: Mary, Queen of Scots or the thoroughly reprehensibly evil Mary I of England.