Amalek, descendants of Esau (Cf Genesis 36:12 ) attacked Israel from the rear, assaulting the stragglers (See Deuteronomy 25:17-18 ).
For us as heavenly pilgrims, their being overtaken in this unexpected way, illustrates the truth of
Galatians 6:1 "If a man be overtaken in any trespass, you who are spiritual restore such a one in a spirit of gentleness, considering yourself lest you also be tempted."
The surprise attack of Amalek (Exodus 17:8 ) is like being overtaken in a fault or sin. The word "overtaken" in Galatians 6:1 equals to being apprehended or taken by surprise. The redeemed, feeding on Christ in the Word, drinking at the gushing water of the Holy Spirit (John 7:37-39 ) can be surprised with a temptation and even be overtaken with a fault. This is not the deliberate sinner who is in need of conviction, repentance and the new birth. Paul is talking about the surprised, fallen, or stumbled saint.
Instructions are given.
Restoring has to be done:
By Whom?
You who are spiritual. That is, one who has spiritual understanding of the Word (1 Corinthians 2:14
); one manifesting developed fruit of the Spirit (Galatians 5:22,23 ); one who is living the Holy Spirit
controlled life (Ephesians 5:18 ).
What Has to Be Done?
Restore to grace in Christ, to rightful standing and place in Christ; to recover, re-equip and restore to full
function and walk with God.
How Are Such to Be Restored?
In a spirit of gentleness. Handling with care as a medical surgeon, remembering your own vulnerability to
temptation, when you are like the Israel stragglers, at the rear of activities, and questioning God (Exodus
17:7 ), and not alert, but tired and weary.
Deuteronomy 25:17-18 "Remember what Amalek did... attacked your rear ranks, all the stragglers ... when you were tired and weary."
Because Amalek descended from Esau (Genesis 36:12 ) the warfare is taken to be illustrative of the struggle of the flesh against the spirit in the believer.
Galatians 5:17 "For the flesh lusts against the Spirit, and the Spirit against the flesh; and these are contrary to one another, so that you do not do the things that you wish."
The secret of not fulfilling the strong desires of the flesh is to walk in the Spirit. (Galatians 5:16 ).
Ryrie says, "Better, by the Spirit, which will give victory over the flesh and its works."
Joshua is told to go and fight - Moses would be on the hill with the rod of God in his hand (Exodus 17:8 ). Notice, this is the first mention of Joshua, in the Bible. He shows three essential leadership qualities, courage, faith, and obedience (Exodus 17:10 ). His secret was his unwavering faith in the Lord. We must learn that spiritual battles are won or lost depending what happens on the hill, rather than on the size of the army in the valley. The upraised hands of intercession - the lifting up of the rod of God, illustrate our warfare against the forces of evil spirits (Ephesians 6:19 ). Israel could only maintain victory in battle as the intercessory hands of Moses remained aloft - and the rod of God was uplifted. The rod here may speak to us of coming in intercession with the promises of God's Word, or praying with the utterance of the Holy Spirit.
1 Corinthians 14:15 "I will pray with the spirit, and I will also pray with the understanding."
Implying that my spirit prays with Holy Spirit utterance so that it becomes the overcoming praying in the Holy Spirit (Jude 20 ). Victory in conflict should be followed by a sacrifice of thanksgiving (Exodus 17:15 ). Moses called the altar which he built, 'The Lord is my banner.' The name of the Lord is the banner beneath which every believer fights the enemy. The relentlessness continues from generation to generation. (Exodus 17:16 ). God uses the battles to discipline His people in being set apart to Him.

Have you proved the power of intercession?
Does the building of the altar after victory over Amalek warn you to maintain an altar of prayer?