The dual themes of ambition and betrayal run throughout Shakespeare's Macbeth, and both are foreshadowed early in the play when the Thane of Cawdor betrays King Duncan, and Duncan gives the title of Thane of Cawdor to Macbeth as a reward for Macbeth's victories in battle.
Duncan is wholly unaware of the irony of the situation.
DUNCAN. There's no art
To find the mind's construction in the face:
He was a gentleman on whom I built
An absolute trust. (1.4.13–16)
At this moment, Macbeth enters the scene. Macbeth has been utterly loyal to Duncan and has represented himself well, if not heroically, in many battles on Duncan's behalf.
Even when the Witches prophesy that Macbeth will be king, Macbeth rejects his previous ambitions for the throne and seems content to wait and see what develops over time.
MACBETH. [Aside.] If chance will have me king, why, chance
may crown me
Without my stir. (1.3.155–157)
It's in act 1, scene 4, however—when Duncan formally declares his son Malcolm as his heir and successor after bestowing the title and property of the traitorous Thane of Cawdor on Macbeth—that Duncan unknowingly rekindles Macbeth's ambition, and seals his own fate.
MACBETH. That is a step [Duncan naming Malcolm as his successor]
On which I must fall down, or else o'erleap,
For in my way it lies. Stars, hide your fires;
Let not light see my black and deep desires ... (1.4.55–58).
Even so, and even after succumbing to Lady Macbeth's own ambitions for Macbeth and herself, Macbeth is at first reluctant to betray Duncan.
MACBETH. ... He's here in double trust:
First, as I am his kinsman and his subject,
Strong both against the deed; then, as his host,
Who should against his murderer shut the door,
Not bear the knife myself. ... (1.7.12–16)
Within a few minutes of deciding not to go through with Duncan's murder, however, Lady Macbeth again prevails on Macbeth to be a man and do what needs to be done to become king.
LADY MACBETH. ... When you durst do it, then you were a man;
And, to be more than what you were, you would
Be so much more the man.
... But screw your courage to the sticking-place,
And we'll not fail. (1.5.55–57, 68-69)
From this point in the play, ambition and betrayal move forward hand-in-hand in the person of Macbeth. It's only a matter of time before Macbeth realizes that his former friend and comrade-in-arms, Banquo, and Banquo's son, Fleance, are significant threats to his throne, and orders them killed.
When Macbeth learns that Malcolm has gone to England to request troops from King Edward to fight against him, Macbeth takes steps to eliminate Macduff, one of Malcolm's strongest military leaders. Macbeth reacts too slowly, however. Macduff has already gone to England to meet with Malcolm, and Macbeth takes out his rage on Macduff's family, which only hardens Macduff's resolve against Macbeth.
In time, Macbeth's "vaulting ambition ... o'erleaps itself" (1.5.27), and Macbeth's betrayals of his king, his friends, and his country come to an end with his death.