The passage here appears to be in contradiction with Acts 20:22, where the Spirit compels Paul to go to Jerusalem.
Acts 20:22 And now, compelled by the Spirit, I am going to Jerusalem without knowing what will happen to me there, 23 except that the Holy Spirit warns me in town after town that imprisonment and persecutions are waiting for me.
How then do we reconcile them? Are the disciples here acting in the Spirit when they tell Paul not to go? I have heard some argue that the people were using the gift of prophecy incorrectly (as seen in 1 Corinthians 12:7-10). However, the word used here is dia which does not always mean primary, direct agency. (Though it can mean that, cf Acts 28:25.)
According to the lexicons (Friberg, UBS, Louw-Nida, LEH), we can understand dia to be "by reason of" what the Spirit had revealed. In other words, it is because of what the Spirit first said that the believers reacted this way. They had great love for Paul and upon hearing something from the Spirit (likely a warning of what was to come), they did not want him to go.
The use of upo as in Acts 13:4 would indicate they were doing this "under the power of the Spirit."
Like other gifts of the Holy Spirit, prophecy must be judged. In Acts 17:11, the Bereans were praised because they confirmed with the Scriptures what was told to them. Another reason that prophecy must be judged is because the speaker's (and hearers') emotions can get in the way. Like Agabus in just a few verses, the Spirit showed them what would happen (then, Paul bound and imprisoned; here, likely something similar though it is not detailed). They drew their own incorrect conclusions from there.