The motte-and-bailey fallacy occurs when an arguer switches between an indefensible (or difficult to defend) opinion to a more defensible one on the same topic, but after defending that stronger position, claims that the weaker position has thereby also been defended or proven.
In practice, this often takes the form of headlining an extreme or controversial position with a less extreme motto or slogan that sounds innocuous and to which almost no one within the sphere of debate would object.
The fallacy is named after the medieval Norman-style motte-and-bailey castle, which had an outer perimeter surrounding a large open area, the bailey, which was just lightly defensible -- and meant to give people enough time, when heavily attacked, to retreat to the motte, a stone tower in the center.

The motte is somewhat dark and cramped inside, and so is less desirable, but it is highly defensible. After retreating to the motte for some time, inhabitants could outlast the invaders, who would eventually give up on attacking the nigh impenetrable tower. Then the occupants would immediately exit the motte and reoccupy the more desirable bailey again.
Analogously, when committing the fallacy, an arguer whose position is being attacked retreats to a highly defensible representation of that position, but uses a successful defense of this position to move back to the far less defensible one. If the weak position is attacked again, the arguer can simply retreat again to the stronger position, as many times as needed.
This is fallacious because of the pretense that successfully defending the stronger position implies the weaker position is thereby also defended.