The role of the Holy Spirit is to dwell within the heart of Jesus and of man to strengthen and sustain us especially through difficult times. Jesus was tempted by the devil while He was in the wilderness for forty days and forty nights, he taught he could use his power over Jesus because Jesus was at his lowest, He was tired and hungry.
The Spirit was within Jesus and He rebuked the devil each time he tried to tempt Him by using the mighty words of the scriptures. God give Him authority over the devil. For example, when the devil wanted Jesus to bow down and worship him, Jesus said "get thee behind me Satan, for it is written, You shall worship the Lord your God, and Him only shall you serve."
Like Jesus we should be obedient to the Word of God and the commands He give us, speak authority to the devil and he will flee from you. And when the Holy Spirit dwells within us we will be set free from all unrighteousness.
When we confess our sins and receive Jesus as our Lord and Savior, do everything through the strength and will of God then we are led by the Holy Spirit who lives in us.