Exact inverses. Chekhov's gun fires what was planted; deus ex machina fires what was never planted. One rewards the attentive reader; the other tells them their attention was wasted.
Side by side
Aspect
Deus ex machina
Chekhov's gun
Setup
None
Required
Arrives from
Outside the plot
Inside it
Reader feels
Cheated
Rewarded
Aristotle's view
Forbidden
—
What each one means
Deus Ex Machina
An improbable outside force nobody set up, which turns up and resolves a plot's difficulties — usually at the end. Originally literal: a god lowered onto the Greek stage by a crane to sort the story out.
Chekhov's gun is the rule that nothing conspicuous should sit in a story unless it's going to matter. Chekhov stated it as a rule about removal — if the rifle won't fire, take it off the wall — and in current usage it also names the planted detail itself: the object that turns out to matter.