In 7.11 The Perfect Society: Four Social Classes) of Śrīmad-Bhāgavatam (Bhāgavata Purāṇa), Nārada Muni says
यस्य यल्लक्षणं प्रोक्तं पुंसो वर्णाभिव्यञ्जकम्।
यदन्यत्रापि दृश्येत तत्तेनैव विनिर्दिशेत् ॥३५॥
If one shows the symptoms of being a brāhmaṇa, kṣatriya, vaiśya or śūdra, as described above, even if he has appeared [born] in a different class, he should be accepted according to those symptoms of classification.
Vana Parva: Markandeya-Samasya Parva of Mahabharata
A man, may be born in the Sudra caste, but if he is possessed of good
qualities, he may attain the state of Vaisya and similarly that of a
Kshatriya, and if he is steadfast in rectitude, he may even become a
Brahmana.
Vana Parva: Tirtha-yatra Parva of Mahabharata:
Yudhishthira said, 'In human society, O mighty and highly intelligent serpent, it is difficult to ascertain one's caste, because of promiscuous intercourse among the four orders. This is my opinion. Men belonging to all orders (promiscuously) beget offspring upon women of all the orders. And of men, speech, sexual intercourse, birth and death are common. And to this the Rishis have borne testimony by using as the beginning of a sacrifice such expressions as--of what caste so ever we may be, we celebrate the sacrifice. Therefore, those that are wise have asserted that character is the chief essential requisite.
Santi Parva: Rajadharmanusasana Parva of Mahabharata:
That wretched Brahmana who falls away from his duties and whose
behaviour becomes wicked, becomes, O king, a Sudra.
Vana Parva: Tirtha-yatra Parva of Mahabharata:
A Sudra is not a Sudra by birth alone--nor a Brahmana is Brahmana by birth alone. He, it is said by the wise, in whom are seen those virtues is a Brahmana. And people term him a Sudra in whom those qualities do not exist, even though he be a Brahmana by birth.
Few examples are discussed here where varana got changed based on qualities:
-
From the kṣatriya known as Agniveśya came the celebrated brāhmaṇa
dynasty known as Āgniveśyāyana. (Source: Śrīmad-Bhāgavatam (Bhāgavata
Purāṇa) 9.2)
-
In addition to these nineteen sons mentioned above, there were eighty-one younger ones, all born of Ṛṣabhadeva and Jayantī. According to the order of their father, they became well-cultured, well-behaved, very pure in their activities and expert in Vedic knowledge and the performance of Vedic rituals. Thus they all became perfectly qualified brāhmaṇas [from kṣatriyas]. (Source: Śrīmad-Bhāgavatam (Bhāgavata Purāṇa) 5.4.13
-
That wretched Brahmana who falls awayManu also had a son known as Dhṛṣṭa, from his duties and whosewhom another sect of
behaviour becomes wicked, becomes, O kingkṣatriyas was generated, but although they were born of one who had
the qualities of a Sudrakṣatriya, they became brāhmaṇas." (Source: Santi Parva:
Rajadharmanusasana Parva of Mahabharata:
Śrīmad-Bhāgavatam (Bhāgavata Purāṇa) 9.2)
-
Vishvamitra was a kshatriya king earlier. Later, he undertook intense
penance and attained brahminhood. This is discussed here.