The devil's advocate
Figuratively, one who takes a contrary position for the sake of testing an argument, or just to be perverse.
The term 'Devil's advocate' was brought into English in the 18th century from the medieval Latin expression 'advocatus diaboli'. To describe someone as a Devil's advocate now is to suggest that they are mischievous and contradictory, being contrary for the sake of it. In medieval Europe, Devil's advocate wasn't seen so negatively; it was, like 'chamberlain' or 'cordwainer', a job title.
There are various mentions in Vatican records dating from the early 1500s of an informal role called 'Diaboli Advocatus'. In 1587, the administration of Pope Sixtus V (disappointingly, there hasn't yet been a Sixtus the Sixth) established the formal post of Promoter of the Faith, known colloquially as the 'Advocatus Diaboli', which surely must have been the same role as 'Diaboli Advocatus'. The job description wasn't especially onerous, until someone was nominated for either beatification and canonization, at which point the 'Devil's Advocate' was expected to draw up a list of arguments against the nominee becoming blessed or canonised.
The first time that the current form of the expression was used in print appears to be in the 1760 humorous text Impostors Detected:
By rising up and playing the true part of the Devil's advocate.
See also: Between the Devil and the deep blue sea.