In Sanskrit texts, R?ja yoga refers to the goal of yoga (which is usually samadhi) and not a method of attaining it. The term also became a modern retronym, when in the 19th-century Swami Vivekananda equated raja yoga with the Yoga Sutras of Patanjali. Since then, R?ja yoga has variously referred to as "royal yoga", "royal union", "sahaj marg", "classical yoga", and "a?ga yoga".
R?ja (Sanskrit: ) means "chief, best of its kind" or "king". R?ja yoga thus refers to "chief, best of yoga".
The historical use of the term R?ja yoga is found in other contexts, quite different than its modern usage. In ancient and medieval Sanskrit texts, it meant the highest state of yoga practice (one reaching samadhi).Hatha Yoga Pradipika, for example, refers to Hathayoga as one of the ways to achieve R?ja yoga.
The first known use of the phrase "R?ja yoga" occurs in a 16th-century commentary on a specific step in the Yoga S?tras of Patañjali. The Hindu scholar Dattatreya, in his medieval era Tantric work named "Yogastra", explains in 334 shlokas, principles of four yoga: Mantra yoga, Hatha yoga, Laya yoga and Raja yoga.Alain Daniélou states that R?ja yoga was, in the historic literature of Hinduism, one of five known methods of yoga, with the other four being Hatha yoga, Mantra yoga, Laya yoga and Shiva yoga. Daniélou translates it as "Royal way to reintegration of Self with Universal Self (Brahman)".
The term became a modern retronym when in the 19th-century Swami Vivekananda equated raja yoga with the Yoga S?tras of Patañjali. This sense of meaning is different from Hatha Yoga Prad?pik?, a text of the Natha sampradaya, where it is a different practice. Similarly, Brahma Kumaris, a recent religious movement, teaches "R?ja yoga" that has very little to do with either the precepts of Hatha Yoga or Patañjali's Yoga S?tras. Modern interpretations and literature that discusses Raja yoga often credit Patañjali's Yogas?tras as its textual source, but many neither adopt the teachings nor the philosophical foundations of the Yoga school of Hinduism. This mixing of concepts has led to confusion in understanding historical and modern Indian literature on Yoga.
The Shaiva Yoga text, Amanaska, dated to be from the 12th century CE or earlier, is a dialogue between Vamadeva and deity Shiva. In the second chapter, the text mentions Raja yoga, and explains why it is called so. It states that it is so named because it enables the yogin to reach the illustrious king within oneself, the supreme Self. Raja yoga is declared as the goal and a state of samadhi, where one experiences nothing but the bliss of the undisturbed, the natural state of calm, serenity, peace, communion within and contentment.
? ? | ? || ? ||
? | ? ?- || ? ||
? ? | -? ? || ? ||
? ? | ? ? || ? ||
- ? ? ?-? | -?- ? || ? ||
Raja yoga, samadhi, unmani, manonmani, amaratva, laya, tatva, sunya, asunya, parama pada,
amanaska, advaita, niralamba, niranjana, jivanmukti, sahaja and turiya denote the same state of being.
Just as with salt dissolved in water becomes one with it, so the union of Atman and Manas (mind) is denominated samadhi,
When the breath becomes exhausted, and mind becomes Praliyate (still, reabsorbed), they fuse into union called samadhi.
This equality, this oneness of the two, the living self and the absolute self, when all Sankalpa (desire, cravings) end is called samadhi.-- Hath Yoga Pradipika, 4.3 - 4.7, 
Some medieval era Indian texts on Yoga list Rajayoga as one of many types of yoga. For example, the Sarvanga yoga pradipikå, a Braj-bhashya commentary by Sundardas, from the 17th-century, teach three tetrads of Yogas. The first group is Bhakti yoga, Mantra yoga, Laya yoga, and Carcha yoga; the second group is Hatha yoga, Raja yoga, Laksha yoga, and Astanga yoga; the third is Samkhya yoga, Jñana yoga, Brahma yoga, and Advaita yoga. Of these twelve, Sundardas states that Rajayoga is the best yoga.
Raja yoga is a modern retronym introduced by Swami Vivekananda when he equated raja yoga with the Yoga Sutras of Patanjali. After its circulation in the first half of 1st millennium CE, many Indian scholars reviewed it, then published their Bhya (notes and commentary) on it, which together form a canon of texts called the P?tañjalayogastra ("The Treatise on Yoga of Patañjali").
According to Axel Michaels, the Yoga Sutras are built upon fragments of texts and traditions from ancient India. According to Feuerstein, the Yoga Sutras are a condensation of two different traditions, namely "eight limb yoga" (ashtanga yoga) and action yoga (kriya yoga). The kriya yoga part is contained in chapter 1, chapter 2 verse 1-27, chapter 3 except verse 54, and chapter 4. The "eight limb yoga" is described in chapter 2 verse 28-55, and chapter 3 verse 3 and 54.
There are numerous parallels in the concepts in ancient Samkhya, Yoga and Abhidharma schools of thought, particularly from 2nd century BCE to 1st century AD, notes Larson. Patanjali's Yoga Sutras may be a synthesis of these three traditions. From Samkhya school of Hinduism, Yoga Sutras adopt the "reflective discernment" (adhyavasaya) of prakrti and purusa (dualism), its metaphysical rationalism, as well its three epistemic methods to gaining reliable knowledge. From Abhidharma Buddhism's idea of nirodhasamadhi, suggests Larson, Yoga Sutras adopt the pursuit of altered state of awareness, but unlike Buddhism which believes that there is neither self nor soul, Yoga is physicalist and realist like Samkhya in believing that each individual has a self and soul. The third concept Yoga Sutras synthesize into its philosophy is the ancient ascetic traditions of isolation, meditation and introspection, as well as the yoga ideas from the 1st millennium BCE Indian texts such as Katha Upanishad, Shvetashvatara Upanishad and Maitri Upanishad.
In early 11th century, the Persian scholar Al Biruni visited India, lived with Hindus for 16 years, and with their help translated several significant Sanskrit works into Arabic and Persian languages. One of these was Patanjali's Yogasutras. Along with generally accurate translations, Al Biruni's text has significant differences than Yogasutra manuscripts discovered in India, during the 19th century. Al Biruni's record has helped modern scholars establish that Patanjali's Yogasutras manuscript existed in India in many versions, each with multiple commentaries by Hindu scholars. Some of these versions and commentaries have been lost or yet to be found. Al Biruni's translation preserved many of the core themes of Yoga philosophy of Hinduism, but certain sutras and analytical commentaries were restated making it more consistent with Islamic monotheistic theology. Al Biruni's version of Yoga Sutras reached Persia and Arabian peninsula by about 1050 AD.
In Indian historical timeline, marking with the arrival of Islam in India in twelfth century, further development and literature on Yoga philosophy of Hinduism went into decline. By the sixteenth century, Patanjali's Yoga philosophy was nearly extinct. Yoga was preserved by sadhus (ascetics, sannyasis) of India. Some of the Hindu yoga elements were adopted by Sufi sect of Muslims in India. The Sufi Muslims at times adopted and protected the Yoga tradition of Hindus during the Islamic rule of India, and at other times helped the persecution and violence against those Hindus. The Mughal Emperor Akbar, known for his syncretic tolerance, was attracted to and patronized Yoga philosophy of Hinduism.