Deus ex machina.
In Greek and Roman drama, a god lowered by stage machinery to resolve a plot or extricate the protagonist from a difficult situation.
An unexpected, artificial, or improbable character, device, or event introduced suddenly in a work of fiction or drama to resolve a situation or untangle a plot.
A person or event that provides a sudden and unexpected solution to a difficulty.
A deus ex machina (pronounced /ˈdeɪ.əs ɛks ˈmɑːkinə/ or /ˈdiː.əs ɛks ˈmækɨnə/, literally "god from the machine") is a plot device in which a person or thing appears "out of the blue" to help a character to overcome a seemingly insolvable difficulty.
SF&F examples of DEM:
1. In the movie version of The Return of the King an invincible, hitherto-unmentioned Army of the Dead is suddenly revealed to be recruitable by Aragon and saves the day (in the book they are still a bit of a DEM but at least don't resolve the entire storyline on Aragorn's behalf as in the movie). The movie actually suffers from a total logic failure since, having established the Army of the Dead can save the day with no problems whatsoever, Aragorn gets rid of them instead of having them hang around for another week to defeat Sauron in totality as well (as is often the case, Gimli was right all along).
2. At the end of Gardens of the Moon a rampaging aeons-old entity is smashing up a major city when he gets randomly imprisoned by a magic house that materialises suddenly nearby with zero forewarning whatsoever. Later he starts to enjoy staying there and gets a cat. There's quite a few additional Erikson examples of this which I will forebear from mentioning.
Things that are not DEM but are often called as such, to the annoyance of this critic.
1. The Deep Space Nine episode where a the Prophets destroy/displace a Dominion fleet of two thousand ships passing through the wormhole at Sisko's request. A particularly mind-numbing misuse of the term since the Prophets, their mastery of the wormhole, their sheer power and their odd respect for Sisko had been established over the course of no less than 130 previous episodes. Also, since the Federation had already fought its way through over 1,200 Dominion ships (in the biggest single battle in Star Trek's history, before or after) to reach the wormhole in the first place, it couldn't entirely be described as anti-climatic either. This is a logical use of a long-established existing plot point to conclude a dramatic storyline.
2. The conclusion to Peter F. Hamilton's Night's Dawn Trilogy. This one represents a particularly ridiculous use of the term. In Book 1 our heroes learn of the existence of a device in deep space that has enormous powers over space/time manipulation which could be used to resolve the crisis. In Book 2 this information is processed, analysed and discussed at length. In Book 3 our heroes deliberately go in search of this device, spending enormous resources and time tracking it down. When they find it, they discover that, shockingly, it can be used to resolve the crisis, and employ it for this purpose. Again, this is a logical use of a plot point established no less than about 2,600 pages earlier to logically conclude a dramatic storyline. The use of this device also has significant consequences, as it is not in the slightest a 'reset' button which makes all the problems generated by the crisis just go away. It is a tad on the anti-climatic side with reference to several storylines (most notably the events in London that are in progress at the time) but it is not a DEM ending by any definition.