It is a meditative absorption or trance, attained by a long practice of dhyāna. It is also a spiritual state of being totally aware of the present moment, a one-pointedness of mind.
In Sutra 1:17 Patanjali tells us that samprajnata samadhi comprises four stages: "Complete high consciousness (samprajnata samadhi) is that which is accompanied by vitarka (reasoning), vicara (reflection), sananda (ecstasy), and sasmita (a sense of 'I'-ness)." Sānanda is free from vitarka and vicara.
Ashtanga Yoga lists 4 samadhis : Ishvara-Samadhi(U.P. 16), Savikalpa-Samadhi(U.P.17), Nirvikalpa-Samadhi(U.P.18) and Sahaj-Samadhi(U.P.19)
In Buddhism, samadhi is a state of concentration and also the last of the eight elements of the Noble Eightfold Path.
It has here the meaning of 'concentration' which happens long before the above samadhis of Ashtanga yoga.
There are several forms of Samadhi :