There are two common meanings for the word ecstasy and both meanings can be applicable to BDSM.
Happiness or joyous excitement
Ecstasy can firstly refer to very powerful feelings of happiness or joyous excitement.
How this happens is that the intensity of many BDSM experiences can compel surrender and complete openness to the experience itself. For example, a flogging or bondage scene can create physical or psychological feelings which are so strong that they push all other awareness out of our minds. We can't help but completely surrender to what's happening because the feelings we get from the scene overwhelm everything else.
Indeed, in these types of scene, to get the most out of BDSM this surrender---as opposed to resistance, endurance, or trying to "tough it out"---is necessary. We must actively accept and embrace the experience rather than merely tolerate it happening. This concept of surrender is vital. Emmanuel Ghent notes that it can be accompanied by feelings of ecstasy. See also Peter Masters.
These BDSM activities can serve to push aside the civilised facade which we need to maintain in order to operate in our wider society and expose our True Selves to achieve more primal satisfaction. This can be very liberating and, in fact, being able to completely expose ourselves---or being compelled to do so by our feelings in the scene---helps to create a total immersion in ecstasy.
Ecstasy doesn't just knock on the door of submissives, slaves and bottoms. Dominants, masters and tops also experience this total immersion through their concentration on their partner. We can perhaps usefully differentiate between these by considering that tops, masters and dominants experience an outwardly-focussed total immersion, while submissives, slaves and bottoms experience an inwardly-focussed total immersion.
This form of ecstasy usually last only a short time, from seconds up to perhaps half an hour, though under some circumstances it can last considerably longer. There can be some overlap with subspace (see below).
Frenzy or trance
The second form of ecstasy we can see in BDSM often strongly overlaps with the experience of subspace. This is an altered state of mind which, instead of being associated with great excitement or happiness, as above, is more quiet or meditative. Rather then being hyper, it is hypo.
This form of ecstasy can last for minutes, hours, or even days.
For more on this, see the article on subspace.