Shakya (Sanskrit: Śākya, Devanagari: शाक्य, Pāli: Sākya) is a Suryavanshi  Kshatriya  clan of the ancient Vedic period(1500-500 BCE). The name is derived from the Sanskrit word śakya which means capable, able. The Genealogy of Shakyas is found in Book IV of the Vishnu Purana, the Bhagavata Purana and the Brahma Purana.
The Śākyas formed an independent republican state, known as Sakya Gaṇa-rājya. The Śākya capital was Kapilavastu (Pāli: Kapilavatthu) in present-day Nepal, which lies near the border of the present-day Uttar Pradesh state of India.
The most famous Shakya was the prince Siddhartha Shakya (5th century BCE) who was the founder of Buddhism and came to be known as Gautama Buddha. Siddhartha was the son of Suddhodana. Suddodhana was the elected leader of Shakya Republic. As Gautama Buddha founded a new religion and abdicated the throne, so the lineage continued with his son Rahula.
The accounts of the Purāṇas
King Shakya was one of the last descendants of Ikshvaku dynasty, commonly known as Suryavansha, as Ikshvaku was the grandson of Vivasvan (Surya). Rama was one of the earlier descendants of Ikshvaku. Other well known descendants include Satyavarta, Harishchandra, Bhagiratha, Raghu (after whom this dynasty also came to be known as Raghuvansha), Dasharatha father of Rama etc.
The accounts of Buddhist texts
The Śākyas are mentioned in later Buddhist texts as well including the Mahāvastu (c. late 2nd century BCE), Mahāvaṃsa and Sumaṅgalavilāsinī (c. 5th century CE), mostly in the accounts of the birth of the Buddha, as a part of the Adichchabandhus (kinsmen of the sun) or the Ādichchas (solar race or Suryavansh) and as descendants of the legendary king Ikṣvāku (Pāli: Okkāka)
There lived once upon a time a king of the Śākya, a scion of the solar race, whose name was Śuddhodana. He was pure in conduct, and beloved of the Śākya like the autumn moon. He had a wife, splendid, beautiful, and steadfast, who was called the Great Māyā, from her resemblance to Māyā the Goddess.—Buddhacarita of Aśvaghoṣa, I.1-2
The Buddhist text Mahavamsa (II, 1-24), traces the origin of the Sakyas (Śākyas) to king Okkaka (Ikshvaku) and gives their genealogy from Mahasammata, an ancestor of Okkaka. This list comprises the names of a number of prominent kings of the Ikshvaku dynasty, which include Mandhata and Sagara. According to this text, Okkamukha was the eldest son of Okkaka. Sivisamjaya and Sihassara were the son and grandson of Okkamukha. King Sihassara had eighty-two thousand sons and grandsons, who were together known as the Sakyas. The youngest son of Sihassara was Jayasena. Jayasena had a son, Sihahanu, and a daughter, Yashodhara (not to be confused with prince Siddhartha's wife), who was married to Devadahasakka. Devadahasakka had two daughters, Anjana and Kaccana. Sihahanu married Kaccana, and they had five sons and two daughters; Suddhodana was one of them. Suddhodana had two queens, Maya and Prajapati, both daughters of Anjana. Siddhartha (Gautama Buddha) was the son of Suddhodana and Maya. Rahula was the son of Siddhartha and Yashodara (also known as Bhaddakaccana), daughter of Suppabuddha and granddaughter of Anjana.
The Brahmin lineage: Gautama Gotra
This is the reason why Buddha is known as Gautam Buddha.
According to the Mahavastu and the Lalitavistara, the seat of the Shakya administration was the saṃsthāgāra (Pali:santhāgāra) (assembly hall) at Kapilavastu. A new building for the Shakya samsthagara was constructed at the time of Gautama Buddha, which was inaugurated by him. The highest administrative authority was the sidharth , comprising 500 members, which met in the samsthagara to transact any important business. The Shakya Parishad was headed by an elected raja, who presided over the meetings.
The Śākyas formed an independent republican state, known as Shakya Ganarajya, at the foothills of the Himālayas. The Śākya capital was Kapilavastu (Pāli: Kapilavatthu). This system of administration is adopted by Constitution of India which identifies India as a republican state or Ganatantra (republic).
The Buddhist literature Mahabagga mentions that:
गण पूरकोवा भविस्सामीति Gaṇa pūrkovā bhavissāmīti
It indicates that there was an officer who used to see the number of ganas and their koram in the Rajasabha (state assembly).
During Buddhist period, the Buddhist books like Pali-pitaka, Majjhamnikaya, Mahabagga, Avadana-shataka have mentioned ganas and sanghas many times. During Buddhas period there were 116 republics or ganasanghas in India.
In Buddhist times, Gaṇas were assemblies of the Sanghas, early democratic republics known as Gaṇa-rājyas, literally "rule of the assembly", a term paralleling demo-kratia or soviet republic. The term was revived in Bhārata Gaṇarājya, the official name of the Republic of India.
Annexation by Kosala
Vidaḍūbha, the son of Pasenadi and Vāsavakhattiyā, the daughter of a Śākya named Mahānāma by a slave girl, ascended the throne of Kosala after overthrowing his father. As an act of vengeance for cheating Kosala by sending his mother, the daughter of a slave woman, for marriage to his father, he invaded the Śākya territory, massacred them and annexed it.
The ancient Buddhist texts Mahavamsa and Jain literature Punyashrava Katha Kosh, trace the origin of Maurya dynasty from the Shakya clan. According to this account, the Mauryans were a group of Shakyas who fled from Kapilvastu to Pipphalvana after Virudhaka attacked their kingdom.
According to Mahavamsa, the Sri Lankan kings Panduvasdeva of Upatissa Nuwara (504-474 BCE) and his descendant Pandukabhaya of Anuradhapura (437-367 BCE), beonged to a branch of the Shakya clan descended from Gautama Buddha's cousin Pandu Shakya.
According to Hmannan Yazawin, first published in 1823, the legendary king Abhiraja, who founded the Kingdom of Tagaung and the Burmese monarchy belonged to the same Shakya clan of the Buddha. He migrated to the present-day Burma after the annexation of the Shakya kingdom by Kosala. The earlier Burmese accounts stated that he was a descendant of Pyusawhti, son of a solar spirit and a dragon princess.
Migration to Kathmandu (Nepal)
Some Nepalese communities also claim descent from the Shakya clan of the Buddha. According to one legend, after the annexation of Kapilavastu by Virudhaka, one group of Shakyas fled northward to the hills, and settled in western Nepal. In order to hide from persecution, they took the title of Koliya And Moriya. When they learned of the forest monastery in Sankhu established during the time of Buddha, they migrated to Kathmandu Valley under the Kirats. Later, they established two settlements in Yembu and Yengal. In Yengal, they renovated the monasteries of Manjupattan. By Licchavi era, Yembu and Yengal were called Koligram and Dakshin Koligram respectively. They established various monasteries in both settlements, and retook the title of Shakyas in the late Licchavi era. Various monastic traditions are still followed to date in many of these monasteries.
- as per Srimad-Bhagavatam [Canto 9, Ch.12] : The Dynasty of Kusha, the Son of Lord Ramacandra : TEXT 14 Shakyas belong to the dynasty of lord Rama (remember that Rama was Suryavanshi Kshatriya, and obviously he was a Hindu) , An exact sentence derived----> "From Sanijaya will come Sakya, from Sakya will come Suddhoda, and from Suddhoda will come Langala i.e Rahula (As Siddhartha i.e Buddha abdicted the throne) From Langala will come Prasenajit, and from"
- as per History text book "History-Our Past I" (prescribed by NCERT, approved by Ministry of Education, Govt. of India) page 65, The story of the Buddha, An exact sentence derived-----> "The Buddha belonged to a gana known as the Sakya gana, and was a kshatriya." 
- Vishnu Purana CHAP. XXII “”
- Bhagavata Purana, Canto-9, Chapter-12””
- Brahma Purana, Chapters 7 and 8 “”
- [Warder, A.K. (2000), Indian Buddhism, Delhi: Motilal Banarsidass Publishers]
- Chapter 8, Line 10-11
- Law, B.C. (1973). Tribes in Ancient India, Bhandarkar Oriental Series No.4, Poona: Bhandarkar Oriental Research Institute, pp. 245-56
- Misra, V.S. (2007). Ancient Indian Dynasties, Mumbai: Bharatiya Vidya Bhavan, ISBN 81-7276-413-8, pp.285-6
- Geiger, Wilhelm (tr.) (1912). "Mahavamsa, Chapter II". Ceylon Government Information Dept.,Colombo (in lakdvia.org website). Retrieved 2009-10-26.
- (1) The Indian Encyclopaedia, p.2677 
(2) Buddha and Buddhist Synods in India and Abroad By Amarnath Thakur, p.12 
(3) The Life of Buddha as Legend and History By Edward Joseph Thomas, p.22 
- (1) The Indian Encyclopaedia, p.2677 
(2) Buddhism, pg.301 
(3) Buddha and Buddhist Synods in India and Abroad By Amarnath Thakur, p.12 
(4) The Life of Buddha as Legend and History By Edward Joseph Thomas, p.22 
- The Āryan Path of the Buddha, By K. Manohar Gupta, p.71 
- Raychaudhuri H. (1972). Political History of Ancient India, Calcutta: University of Calcutta, pp.177-8
- Kosambi D.D. (1988). The Culture and Civilsation of Ancient India in Historical Outline, New Delhi: Vikas Publishing House, ISBN 0-7069-4200-0, pp.128-9
- Mahavamsa Sections 8, 9 and 10
- Hla Pe, U (1985). Burma: Literature, Historiography, Scholarship, Language, Life, and Buddhism. Singapore: Institute of Southeast Asian Studies. p. 57. ISBN 9789971988005.
- Lieberman, Victor B. (2003). Strange Parallels: Southeast Asia in Global Context, c. 800–1830, volume 1, Integration on the Mainland. Cambridge University Press. p. 196. ISBN 978-0-521-80496-7.
- Rhys Davids, C.A.F. 1926. ‘Man as Willer.’ Bulletin of the School of Oriental and African Studies. 4: 29-44.
- Silk, Jonathan A. 2008 ‘Putative Persian perversities: Indian Buddhist condemnations of Zoroastrian close-kin marriage in context.’ Bulletin of the School of Oriental and African Studies, 71: pp 433–464.
- van Geel, B. et al. 2004. Climate change and the expansion of the Scythian culture after 850 BC: a hypothesis Journal of Archaeological Science. 31 (12) December: 1735-1742.
- Witzel, Michael. 1997. The Development of the Vedic Canon and its Schools: The Social and Political Milieu (Materials on Vedic Śākhās, 8) in Inside the Texts, Beyond the Texts. New Approaches to the Study of the Vedas. Harvard Oriental Series. Opera Minora, vol. 2. Cambridge 1997, 257-345