Thus have i heard. Once Buddha was touring Kosala with about 500 monks and they stayed in a dense jungle of Icchanankala, a kosalan brahmin village. During that time there was a brahmin by the name of Pokkharasati who was living at Ukkhatta and he heard of Buddha, the fully enlightened one, the arahant who was fully perfected and a teacher of man and devas. He had heard praises of Buddha's teaching of the dhamma which is lovely at the bginning, lovely in its middle and lovely in its ending. Brahmin Pokkharasati has a pupil by the name of Ambattha who was well versed inthe vedas, mantras, a skilled expounder of rites and rituals whom he asked to go see Buddha to see if the praises of Buddha is true. He asked his pupil to test Buddha and see if he has the 32 marks of a Great Man and to justify if Buddha is the fully enlightened one. Ambattha, with all the pride and arrogance of youth, traveled by carriage with an entourage of young men into the dense jungle where Buddha was. He rode as far as the carriage would go then dismounted and walked to where the Buddha was living. Ambattha met some monks who were doing walking meditation and he asked them where Buddha was. The monks thought that buddha would not mind talking to such a young man and so they directed him to Buddha's dwelling. They told him to knocked on the door and cough. Buddha answered the door, they exchanged courtesies but the arrogant Ambattha refused to sit and instead walked up and down even when Buddha took his seat.
Buddha asked Ambattha: " well, would you treat your brahmin teachers like this walking and standing while i am sitting down?" Then Ambattha brought up a defense using the caste system which existed according to the vedas. Ambattha said that " I will show full respect for a fellow Brahmin who is of upper cast but i will not show respect to those who are from Brahma's foot (referring to ascetics like Buddha)." According to the vedas studied by brahmins there are four castes born from the brahma god: Brahmins (priests) from Brahma's mouth, Ksatriya (kings and warriors) from Brahma's shoulders, Vaisyas (merchants and traders) from Brahma's thighs and Sudras (servants, slaves, farmers) from brahma's feet . So Ambattha thinks that he being a brahmin, the highest caste , he does not need to pay respect to the lower castes.
Buddha told Ambattha " But you came here seeking an answer and you should listen attentively to learn. But you have not perfected in your training and your ego is due to your inexperience." Ambattha was angry and displeased as he was being called untrained hence he cursed and insulted Buddha and Buddha's Sakyans clan.
Buddha asked Ambattha why he was displeased with the Sakyans, he replied that they did not pay respect to the brahmins and deduced that they made fun of him when he and his teacher visited Kapilavatthu. Buddha suggested to Ambattha that he had overreacted and that the Sakyans can do what they want in their own place just like how a little bird can talk as she likes in her own nest. But Ambattha went on again to say that Sakyans are inferior to Brahmins who were higher caste. Buddha thought that this young man had gone far to insult Sakyans again so he asked Ambattha : " what is your clan?" Ambattha replied: "I am a Kanhayan."
Then Buddha decided to use Ambattha's lineage to ease his ego. Buddha then explained according to ancestral lineage, the Kanhayan were subject to the Sakyans and that Ambattha is descended from King Okkaka, as are the Sakyans, but through a slave girl named Disa, who had a black child, named Kanha (‘black’). Hence the name of his family as "Kanhayan". The name of the Sakyans, on the other hand, means, strong as teak (saka). The Sakyans descended from the four elder legitimate sons of King Okkaka, who intermarried with their own sisters to maintain the blood purity of the Sakyan line. Buddha showed Ambattha in this way that his birth is inferior to the Buddha’s, based on Ambattha’s own line of thinking. This analogy is an excellent example of how the Buddha used common ground to communicate and explain things to his audience.
At this moment, the other young men who came with Ambattha were unhappy and they asked Buddha not to humiliate Ambattha who was well born of good family, learned and a scholar. Buddha told the young men to speak on Ambattha's behalf should they think he is inferior but if they think that Ambattha is able to hold on his own then let Ambattha talk instead of them. The young men kept quiet thereafter.
When pressured by the Buddha three times, Ambattha acknowledged that Dasi, the king’s slave, was in fact the ancestor of the Kanhayans, at which his friends exclaimed in shock that he was ill born. Buddha thought that it was not very nice for Ambattha's friends to humiliate him so he decided to help defend Ambattha. He told them that Kanha although he was a son of a salve-girl he was a great mighty sage who was well versed with mantras. When Kanha went to King Okkaha and asked for his daughter Maddarupi as wife, the king was angry and despised him. Then Kanha being a great sorcerer put a spell on the land so the King Okkaha relented and let him marry his daughter despite his "caste". Buddha knew that Ambattha was attached to the caste system during that time hence he used his ancestral lineage and this analogy to illustrate and explain to him that brahmins are not the highest caste.
Buddha wanted to teach Ambattha further so he asked him "what the caste of the son (Khattiiya) of Brahmin woman and Kshatriya man would be?." Ambattha recognized that the son would both be accepted as Brahmins, but not Ksatriyas, because of the mixed marriage (not well born on mother's side). Similarly should a Brahmin man marry a Ksatriya woman, their son would be accepted as Brahmins but not Ksatriya because he is not well born on father's side. Buddha further asked Ambattha would a disgraced expelled Brahman be honored by Brahmins, Ambattha replied "no". He then asked Ambattha would a disgraced expelled Ksatriya be honored by the Brahmins, Ambattha replied "yes." So in other words, if a Ksatriya suffered extreme humiliation, he is more superior than a brahmin.
Buddha is not trying to prove to Ambattha that Ksatriya is the most powerful caste but rather he is trying to make Ambattha who is a staunch brahmin to know that the vedas belief of brahmins being born from Brahma's mouth is the highest and most supreme caste is untrue. Also Ambattha insulted and humiliated the Kshatriya clan so much so that Buddha thought that it is timely to use these illustrations to let Ambattha know that actually the Ksatriya clan is a strong and powerful clan unlike what Ambattha had thought of them. Hence Buddha finishes off by quoting the Brahma Sanankumara : “The Kshatriya's best among those who value clan; He with knowledge and conduct is best of gods and men.”
Ambattha appears to be finally humbled and asked: "what is the knowledge and conduct that makes one best in the spiritual realm?" Buddha said that knowledge and conduct is attained by the abandonment of all notions of racial and class superiority and inferiority and letting go the ego. He further explained how the ascetics goes forth into the homelessness life, listen to the dhamma taught by the fully enlightened one, practices the moralities, guards their sense doors and attain the four jhanas during meditation. The ascetics then attain various insights, the cessations of the corruptions and taints, walked the eightfold path and achieve enlightenment. There is no further development of knowledge and conduct that is higher or more perfect than an arahant, a fully enlightened one.
Buddha referred this dharma as the “unexcelled attainment,” he mentioned that there are four ways that one can fail to achieve attainment which depend on how one get his daily food: by windfalls, by digging tubers and roots, by tending the flame of a fire hearth at the edge of a village, and finally by building a guest house for those who have attained at a crossroads. It seems to imply that a truly attained person does not gather food for himself, not even windfalls, but rather presumably by the Buddhist practice of alms. Buddha clarified by saying since neither Pokkharasati nor Ambattha do this, they are incapable of attaining the unexcelled knowledge and conduct and so their claims to be more superior and powerful than the buddhist ascetics at the start were untrue.
Buddha then clarified saying that Pokkharasati and Ambattha just memorize the sacred vedas texts by heart but they do not become a sage nor do they practice like a sage. He proved his statement by asking Ambattha whether those ancient sages were addicted to the pleasures of the five senses, eating fine foods, entertain and associate themselves with women, riding about in fine chariots, or guarded by soldiers in cities, like Ambattha and his teacher. Ambattha replied "No." Therefore, the Buddha concluded again that neither Ambattha nor his teacher are sages nor trained in the ways of sages. They are just charlatans, and as such not entitled to the "great respect and honor" that they demanded from others.
After this long explanation, the Buddha got up from his seat, went outside and began to walk up and down so that Ambattha can follow to examine his body for the marks of a great man, which was his original purpose to see the Buddha in the first place. Buddha felt obliged and showed him the 32 marks of a Great Man so that Ambattha could accomplish the mission sent by his teacher.
When Ambattha went back to his Brahmin teacher Pokkharasati, he reported that Buddha was indeed as reported a truly fully enlightened one with the 32 marks of a Great man and he went into details of the conversation between himself with the Buddha. After hearing this, Pokkarasati was furious that Ambattha had been so rude to the Buddha. He was so angry that he kicked Ambattha, knocked him down and wanted to go to see the Buddha himself. As it was late, the other brahmins advised him to go the next day. But Pokkharasati having gone home, ate a meal and then left for where the Buddha was assisted by the light of torches by a chariot, and then by foot.
After Pokkharasati met Buddha, he asked him about the conversation between him and his pupil Ambattha. Buddha related the whole conversation to him and Pokkharasati apologized on his pupil's behalf as Ambattha was young, arrogant and rude to Buddha. Buddha pardoned him. Then Pokkharasati looked out for the 32 marks of a Great man himself and he concluded that Buddha indeed had all of them. He then invited Buddha over to his place for a meal together with the sangha.
After the meal at Pokkharasati's residence, Buddha delivered a graduated discourse on generosity (dana), morality (sila), on heaven, the dangers and corruption of sensual desires and the benefits of renunciation. When Buddha knew that Pokkharasati's mind was ready and free from hindrances, joyful and calm, Buddha went on to talk of the dhamma in brief: he told him about the four noble truths (there is suffering, there is origin of suffering, there is an end to suffering and the noble eightfold path leading to the end of suffering).
Just like a clean cloth removed of all stains, there arose the pure and spotless dhamma-eye in Pokkharasati and he knew " Whatever things have an origin must come to cessation. " (Impermanence and dependent origination). Pokkharasati declared : " Excellent! Excellent! Excellent! How wonderful are the teachings of buddha. I will go with my son, my wife, my ministers, my counselors for refuge to the Buddha (Reverend Gotama), to the Dhamma and to the sangha. May Buddha accept me as a lay follower as long as my life lasts."
So in summary, this sutta is a debate against the caste system set by the brahmins which they strongly believe they are the highest castes of all. As Ambattha was very aggressive and insulting towards the Sakyan Ksatriya clan from the start, Buddha defused his ego by tracing back his ancestral lineage. However when the other brahmins chided Ambattha , Buddha defended him again. Buddha is a believer of no castes system.
References: 1. www.accesstoinsight.org 2. https://suttacentral.net/ 3. The long discourses of the Buddha (Bhikkhu Bodhi)