Breakdown of Ele fez exatamente o contrário do que pedi.
fazer
to do
pedir
to ask for
exatamente
exactly
o contrário
the opposite (as in "on the contrary")
Questions & Answers about Ele fez exatamente o contrário do que pedi.
Why is it "do que" and not just "de que"?
The phrase uses the contraction of de (of) + o que (what / that which). When you say 'the opposite of what', you are literally saying 'the opposite of that which'. The o acts as a pronoun meaning 'the thing' or 'that', while que means 'which'. If you just used de que, it would be grammatically incomplete here.
I've seen "do que" used to mean 'than' in comparisons. Is that happening here?
That is a very common use, but no, this is different! In a comparison like maior do que (bigger than), it functions as a set phrase. Here, it is taken literally: de (of) + o que (what). It simply links o contrário (the opposite) to the clause that describes it.
Why do we use "pedi" instead of "perguntei" for 'I asked'?
English uses 'ask' for both making a request and asking a question. In Portuguese, these concepts are strictly separated. You use pedir when requesting an action or an object (like asking someone to do something), and perguntar when asking for information. Since the sentence refers to an action that was requested of him, pedi is the correct choice.
Since the asking happened before he did the opposite, shouldn't it be "do que tinha pedido" (had asked)?
Using the past perfect here—do que tinha pedido—is absolutely correct and sounds very natural. However, everyday Portuguese often simplifies this by using the simple past (pedi) for both verbs when the logical sequence of events is completely obvious, as it is in this sentence.