Step 1: Read the active sentence.
The peon opened the gate.
Step 2: Identify the parts.
Subject is the peon, verb is opened (simple past), and object is the gate.
Step 3: Recall the passive formula.
Object plus was or were plus past participle plus by plus subject.
Step 4: Pick the auxiliary.
The gate is singular and the tense is past, so we use was, giving was opened.
Step 5: Assemble the sentence.
The gate was opened by the peon.
Step 6: Reject the others.
is opened shifts to present, were opened wrongly uses a plural verb, and has opened changes the tense, so option D is correct.
\[ \boxed{\text{D. The gate was opened by the peon.}} \]