The word havdalah, distinction or separation, is a rabbinical
term for the benedictions and prayers by means of which a division is made
between times of varying degrees of holiness for (such as between Sabbath
and work-day, festival and work-day, or Sabbath and festival). Rabbinical
law required a formal distinction between holy and profane times, a ritual
division that would allow for the resumption of ordinary work after a holy
day. We learn in the Babylonian Talmud that "the men of the Great Synagogue
instituted blessings and prayers, sanctifications and Havdalot for Israel"
for this purpose. 
At the core of the Havdalah ceremony marking the end of the
Sabbath are four blessings; the first three involve rituals of wine, spices,
and flame, each appealing to a different sense: taste, smell, and sight. These
ancient practices predate the schools of Hillel and Shammai, who already debated
the exact order of their use. 
Blessing recited over wine ("Creator of the fruit of
the vine"), marking the distinction between holy and profane with wine
much as we marked it when the day began (in Kiddush). [more
Blessing recited over spices ("Creator of various spices");
various explanations have been offered; [more
Blessing recited over lights ("Creator of the lights
of flame") indicating that work is now permitted and thus stressing
the departure of the Sabbath [more
A fourth and final blessing focuses on a number of distinctions,
e.g. "between the Sabbath and the other days of the week." Known
from early times in various versions, these versions differed primarily in
the number of distinctions they contained. In the Talmud it is laid down that
"He who would recite but few distinctions, must recite not less than
three, but he who would proliferate must not recite more than seven."
R. Judah ha-Nasi, however, recited only one, the distinction "between
the holy and the profane."  Poetic versions containing seven distinctions
have been preserved in the Genizah fragments.
The order of the Havdalah blessing that came to be accepted
is noted by the mnemonic word y-b-n-h, formed from the initial letters
of wine, spices, light, separation (yod for yayin, bet for
besamim, nun for ner, heh for havdalah.)
During medieval times, Ashkenazi communities added a number
of verses which gave expression to the concept of redemption and deliverance;
these served as "a good omen," a gesture of appeal for God's help
in facing the uncertainties and struggles of the coming week. 
Behold the God who gives me deliverance!
I am confident, unafraid;
For Yah the Lord is my strength and might,
And He has been my deliverance.
Joyfully shall you draw water
From the fountains of deliverance. 
Deliverance is the Lord's; Your blessing be upon Your people! 
The Lord of hosts is with us; the God of Jacob is our haven.  So
may it be for us!
The Jews enjoyed light and gladness, happiness and honor. 
I raise the cup of deliverance and invoke the name of the Lord. 
It became customary to sing hymns at the at the close of the
Havdalah ceremony. Of these, several contain references to the prophet Elijah,
who according to one tradition, Elijah will make his appearance at the conclusion
of Shabbat to announce the coming of the Messiah.