The Buddha shares the gradual training guidelines in the Dhamma and discipline with the Brahmin Moggallāna. It is through a gradual practice and gradual progression per these guidelines that one attains the ultimate goal of Nibbāna.

Gaṇakamoggallāna sutta - with Accountant Moggallāna

Thus have I heard At one time, the Blessed One was dwelling in Sāvatthi, in the Eastern Park, at Migāramāta's mansion. Then Moggallāna the Accountant, a Brahmin, approached the Blessed One; having approached, he exchanged greetings with the Blessed One. After a cordial and meaningful conversation, he sat to one side. Seated to one side, the Accountant Moggallāna said to the Blessed One:

"Just as, friend Gotama, in Migāramāta's mansion, one can see a gradual training, gradual practice, and gradual progression up to the final step on the staircase; just as among us Brahmins, there is a visible gradual training, gradual practice, and gradual progress in our studies; just as among the archers, there is a visible gradual training, gradual practice, and gradual progress in archery; so too, friend Gotama, for us accountants, whose livelihood is in accountancy, there is a visible gradual training, gradual practice, and gradual progress in accountancy. When we receive a new pupil, we first make him calculate 'one ones, two twos, three threes, four fours, five fives, six sixes, seven sevens, eight eights, nine nines, ten tens' and up to a hundred. Now, friend Gotama, is it possible to describe a similar gradual training, gradual practice, and gradual progress in your Dhamma and discipline?"

Virtuous Conduct

"Indeed, Brahmin, it is possible to set forth a gradual training, practice, and practice in this Dhamma and discipline as well. Just as, Brahmin, a skilled horse trainer acquires a fine thoroughbred and initially trains it in the management of the bit, then proceeds to further training; similarly, friend Brahmin, the Tathāgata initially trains a person thus: 'Come, bhikkhu, be virtuous, restrained with the restraint of the Pātimokkha, endowed with conduct and resort, seeing danger in the slightest faults, and undertake and train in the precepts.'

Sense Restraint

When, Brahmin, a bhikkhu is virtuous, restrained with the restraint of the Pātimokkha, endowed with conduct and resort, seeing danger in the slightest faults, and undertakes the training in the precepts, then the Tathāgata further trains him: 'Come, bhikkhu, guard the doors of your sense faculties. Upon seeing a form with the eye, do not grasp at its signs or features. If the eye faculty remains unguarded, detrimental unwholesome mental states such as covetousness and grief could overwhelm you. Practice restraint, guard the eye faculty, achieve mastery over it. In the same way, when hearing a sound with the ear, do not grasp at its signs or features. If the ear faculty remains unguarded, detrimental unwholesome mental states such as covetousness and grief could overwhelm you. Practice restraint, guard the ear faculty, achieve mastery over it. Similarly, when smelling an odor with the nose, do not grasp at its signs or features. If the nose faculty remains unguarded, detrimental unwholesome mental states such as covetousness and grief could overwhelm you. Practice restraint, guard the nose faculty, achieve mastery over it. Likewise, when tasting a flavor with the tongue, do not grasp at its signs or features. If the tongue faculty remains unguarded, detrimental unwholesome mental states such as covetousness and grief could overwhelm you. Practice restraint, guard the tongue faculty, achieve mastery over it. In the same manner, when feeling a tactile sensation with the body, do not grasp at its signs or features. If the body faculty remains unguarded, detrimental unwholesome mental states such as covetousness and grief could overwhelm you. Practice restraint, guard the body faculty, achieve mastery over it. Finally, when cognizing a mental object with the mind, do not grasp at its signs or features. If the mind faculty remains unguarded, detrimental unwholesome mental states such as covetousness and grief could overwhelm you. Practice restraint, guard the mind faculty, achieve mastery over it.'

Moderation in Eating

When, Brahmin, a bhikkhu guards the doors of his sense faculties well, the Tathāgata further trains him: 'Come, bhikkhu, be moderate in eating. Consider wisely the food you consume not for amusement, nor for indulgence, nor for physical appearance, nor for beautification, but only for the sustenance and maintenance of this body, for keeping it healthy, for aiding the spiritual life, thinking thus: 'I will allay old feelings of hunger without arousing new feelings, and so that I may be healthy and blameless and live in comfort.'"

Dedication to Wakefulness

When, Brahmin, a bhikkhu is moderate in eating, the Tathāgata further trains him: 'Come, bhikkhu, remain devoted to wakefulness. During the day, purify your mind from obstructive states through walking meditation and sitting meditation. During the first watch of the night, purify your mind in the same way; in the middle watch of the night, lie down on the right side in the lion's posture, with one foot overlapping the other, mindful and fully aware, after noting in your mind the idea of rising; in the last watch of the night, rise up and continue purifying your mind from obstructive states through walking meditation and sitting meditation.'"

Mindfulness and Full Awareness

"When, Brahmin, a bhikkhu is devoted to wakefulness, the Tathāgata further instructs him: 'Come, bhikkhu, be endowed with mindfulness and full awareness. Be fully aware when going forward and returning; be fully aware when looking ahead and looking away; be fully aware when bending and stretching; be fully aware when carrying the outer robe, the bowl and wearing robes; be fully aware when eating, drinking, consuming food, and tasting; be fully aware when defecating and urinating; be fully aware when walking, standing, sitting, falling asleep, waking up, speaking, and keeping silent.'

Seclusion

When, Brahmin, a bhikkhu is endowed with mindfulness and full awareness, the Tathāgata further instructs him: 'Come, bhikkhu, dwell in a secluded lodging in the forest, at the root of a tree, in a mountain cave, in a charnel ground, in a jungle thicket, in an open space, or on a heap of straw.' Thus, he dwells in a secluded lodging in the forest, at the root of a tree, in a mountain cave, in a charnel ground, in a jungle thicket, in an open space, or on a heap of straw.

Abandoning the Five Hindrances

After his meal, having returned from the alms-round, he sits down, folding his legs crosswise, setting his body erect, and establishes mindfulness in front of him. He abandons covetousness for the world and lives with a mind rid of covetousness; he purifies his mind from covetousness. He abandons ill-will and hatred, lives with a benevolent mind towards all beings, compassionate for the welfare of all living beings; he purifies his mind from ill-will and hatred. He abandons dullness and agitation, and lives alert and with full awareness; he purifies his mind from dullness and agitation. He abandons restlessness and remorse, lives tranquil and internally serene; he purifies his mind from restlessness and remorse. He abandons doubt, lives having crossed over doubt, unperplexed about wholesome mental qualities; he purifies his mind from doubt.

Dwell in Jhānas

Having abandoned these five hindrances, imperfections of the mind that weaken wisdom, quite secluded from sensual pleasures, secluded from unwholesome mental qualities, he enters and dwells in the first jhāna, which is accompanied by reflection and examination, born from seclusion, and is filled with joyful pleasure. With the settling of reflection and examination, he enters and dwells in the second jhāna, which is characterized by internal tranquility and unification of mind, is without reflection and examination, born from collectedness, and is filled with joyful pleasure. With the fading away of joyful pleasure, he dwells in a state of equanimity, mindful and fully aware, experiencing ease with the body. He enters and dwells in the third jhāna which the Noble Ones describe as 'one who dwells equanimous, mindful and at ease.' With the abandonment of ease and discontentment, and with the settling down of joy and sorrow, he enters and dwells in the fourth jhāna, which is characterized by purification of mindfulness through equanimity, experiencing neither-painful-nor-pleasant sensation.

Those bhikkhus, Brahmin, who are trainees, aspiring for the unsurpassed security from bondage, abide thus. But those bhikkhus who are arahants, who have exhausted the taints, who have lived the spiritual life, done what was to be done, laid down the burden, attained their true goal, utterly exhausted the fetters of existence, and are completely liberated through final knowledge, for them these teachings lead to dwelling in ease here and to mindfulness and full awareness."

Who Attains Nibbāna

Thus having spoken, the Brahmin Accountant Moggallāna asked the Blessed One: "friend Gotama, do all your disciples who are instructed and guided by you in this way attain final Nibbāna without exception, or do some not attain it?"

"Some of my disciples, Brahmin, being instructed and guided by me in this manner, attain final Nibbāna, the ultimate goal, while others do not."

"What is the cause, friend Gotama, and what is the reason that while Nibbāna exists, the path leading to Nibbāna exists, and you, Gotama, are present to encourage, yet when instructed and guided by you, some of your disciples attain final Nibbāna, the ultimate goal, while others do not?"

"Then, Brahmin, let me ask you a question in return. Answer as you see fit. What do you think, Brahmin, are you skilled in the path to Rajagaha?"

"Yes, Gotama, I am skilled in the path to Rajagaha."

"What do you think, Brahmin, if a man came to you wishing to go to Rajagaha, and said, 'Sir, I wish to go to Rajagaha; show me the way there.' You would tell him, 'This is the way, go in this direction, and after a while, you will see such and such a village, continue and you will see such and such a town, proceed further and you will find yourself in delightful parks, forests, and lands around Rajagaha.' If, after being instructed by you, this person were to take a wrong turn and go backwards, whereas another person, following your instructions, reaches Rajagaha safely, what is the cause, Brahmin, what is the reason why, despite the path to Rajagaha and your instructions, one person goes astray and another reaches Rajagaha?"

"What can I do, Gotama, in that situation? I am only the one who shows the way."

"Similarly, Brahmin, Nibbāna exists, the path leading to Nibbāna exists, and I am here to instruct; yet my disciples, being instructed and guided by me, some attain final Nibbāna and some do not. What can I do, Brahmin? I am only the one who shows the way."

Upon hearing this, the Brahmin Accountant Moggallāna said to the Blessed One: "There are those, friend Gotama, who lack faith, who have left the household life for a livelihood, not out of faith. They are deceitful, insincere, boastful, impudent, unstable, garrulous, unrestrained in their senses, indulgent in food, and not devoted to wakefulness. They do not respect training, are careless, trivial, and lead the spiritual life with a motive of gaining position. They are lazy, lacking energy, forgetful, lacking mindfulness, uncollected, with their minds scattered, and lacking wisdom. These, friend Gotama, do not live in close association with you.

But those clansmen who have left the household life out of faith, who are not deceitful, insincere, or boastful, who are not impudent, unstable, or garrulous, who guard their senses, are moderate in eating, devoted to wakefulness, regard training highly, and strive earnestly in the spiritual life these, friend Gotama, do live in close association with you.

Just as among roots, black pepper is reckoned as the best, among scents the red sandalwood, and among flowers the jasmine; similarly, your advice is supreme among the highest truths.

Excellent, friend Gotama! Excellent, friend Gotama! Just as if one might set upright what had been overturned, reveal what had been concealed, point out the way to one who was lost, or hold up a lamp in the dark so that those with eyes could see forms, in the same way, friend Gotama, the Dhamma has been explained by you in many ways. I go for refuge to venerable Gotama, to the Dhamma, and to the community of bhikkhus. May venerable Gotama remember me as a lay follower who, from this day forward, has gone to refuge for life."