In the beginning of Jesus's ministry, the Pharisees were angered at Jesus but were afraid of what the crowd thought if they were to arrest Jesus. "They looked for a way to arrest him, but they were afraid of the crowd because the people held that he was a prophet." Matthew 21:46. So, it makes me wonder how they mustered up the courage to arrest Jesus if he became more and more popular. How did they know that if they were to arrest Jesus, the crowd wouldn't turn against them after the display of the crowd just laying down palm trees when Jesus arrived in Jerusalem singing "Hosanna to the Son of David!"?
As you rightly point out, the Jewish religious leaders were afraid to arrest Jesus in case the crowds turned against them and caused a riot. Two days before the Passover and the Feast of Unleavened Bread, the teachers of the law were looking for some sly way to arrest Jesus and kill him.
But not during the Feast,” they said, “or the people may riot” (Mark 14:1-2).
My NIV Study Bible notes remark that the population of Jerusalem increased from about 50,000 to several hundred thousand. It would have been too risky to apprehend Jesus with so large and excitable a crowd present.
However, while Jesus was in Bethany, eating at the table of Simon the Leper, Jesus was anointed with very expensive perfume. This displeased many, but none more so than Judas Iscariot, who was entrusted with the money that was given to Jesus and the disciples.
It was at this point that Judas Iscariot went to the chief priests to offer to betray Jesus to them (Mark 14:10). This was the unexpected opportunity the chief priests were looking for. Judas would betray Jesus with a kiss on the evening of the 14th day of Nisan, when the Passover lamb would be sacrificed. After partaking of the meal with Jesus and the other disciples, Judas slipped out to inform the Jewish religious leaders that he would identify Jesus at the place called Gethsemane. Now they could make the arrest under the cover of darkness, far from any curious eyes.
The arrest of Jesus was pre-meditated. The warrant for Jesus’ arrest had been hastily issued by the Sanhedrin. A crowd, armed with swords and clubs, sent from the chief priests, the teachers of the law and the elders, accompanied Judas. They had lost their fear the moment Judas enabled them to arrest Jesus in total darkness, and without any crowds present.
As a matter of interest, the betrayal of Jesus was prophesied hundreds of years before its fulfilment (Psalm 41:9):
Even my close friend in whom I trusted, who ate my bread, has lifted his heel against me.
I found an interesting article on the six parts to Jesus’ trial, three stages were in a religious court and three stages were in a Roman court. https://www.gotquestions.org/trials-of-Jesus.html
When did the Pharisees stop being afraid to arrest Jesus?
If the truth be known, they never stopped fearing the outcome of arresting and putting Jesus to death.
Their hatred of Jesus and his teaching overrode all the fear they may have had about arresting Jesus.
This is bore out in just before Jesus was arrested, when Caiaphas was in council with the leaders and priests of the Jewish nation.
3 Then assembled together the chief priests, and the scribes, and the elders of the people, unto the palace of the high priest, who was called Caiaphas,
4 And consulted that they might take Jesus by subtilty, and kill him.
5 But they said, Not on the feast day, lest there be an uproar among the people.- Matthew 26:3-5
Again they showed their fear of Jesus and his teachings after his death on the Cross.
The Guard at the Tomb
62 The next day, the one after Preparation Day, the chief priests and the Pharisees went to Pilate. 63 “Sir,” they said, “we remember that while he was still alive that deceiver said, ‘After three days I will rise again.’ 64 So give the order for the tomb to be made secure until the third day. Otherwise, his disciples may come and steal the body and tell the people that he has been raised from the dead. This last deception will be worse than the first.”
65 “Take a guard,” Pilate answered. “Go, make the tomb as secure as you know how.” 66 So they went and made the tomb secure by putting a seal on the stone and posting the guard. - Matthew 27:62-66
The incident that ultimately lead the Scribes and Pharisees to overlook their fear about arresting Jesus was when Jesus raised Lazarus from the dead.
According to the Gospel of John, the news that Jesus raised Lazarus from the dead spread like wild fire. Caiaphas the high priest and the Jewish council of the Sanhedrin were enraged. This kind of miracle would surely seduce the people to follow Jesus into rebellion. The fear was that such a rebellion would provoke a clampdown by the Romans.
Then the chief priests and the Pharisees called a meeting of the Sanhedrin.
“What are we accomplishing?” they asked. “Here is this man performing many signs. If we let him go on like this, everyone will believe in him, and then the Romans will come and take away both our temple and our nation.”
Then one of them, named Caiaphas, who was high priest that year, spoke up, “You know nothing at all! You do not realize that it is better for you that one man die for the people than that the whole nation perish.” (John 11:47-50)
“I am the resurrection and the life. The one who believes in me will live, even though they die; and whoever lives by believing in me will never die. Do you believe this?”
Protecting power and public order was now the real priority and Caiaphas the high priest knew that Jesus must die. - Caiaphas the High Priest - Jesus Considered a Threat
The crowds did welcome Jesus when He entered Jerusalem less than a week before His death — and yes, they did turn against Him only a few days later. The Bible says they shouted to Pilate (the Roman governor), “Take him away! Take him away! Crucify him!” (John 19:15).
The Pharisees didn't have the courage to arrest Jesus in the daytime because the crowds were going to protest if they do so. So they came to arrest Jesus in the night.
Every day I sat in the temple courts teaching, and you did not arrest me - Matthew 26:55
Jesus Christ was arrested and beaten by the Roman soldiers in the night before Peter denied Him three times. Rather than Him overthrowing the Roman government, the news of Jesus beaten by them was the reason. The reason was expectation was quite contrary to the reality that is happening right in front of them on the next day morning, thereby the disappointment has taken place. On top of this, Judas himself who is one of the twelve disciples deceived Jesus which is again a good excuse for the Pharisees and chief priests to convince some of the gullible audience.
But the chief priests and the elders persuaded the crowd to ask for Barabbas and to have Jesus executed - Matthew 27:20
Many expected Jesus would declare Himself to be their king, and would lead a revolt against the Romans who were occupying the Jewish nation. In other words, they hoped Jesus would become a political leader. This is the same reason why the disciples were downcast when Jesus Christ was crucified. (cf. Luke 24:13-35)
But Jesus didn’t come to set up a new political system. He came instead to change our hearts and save us from our sins by His death and resurrection. He declared during that last week,
“My kingdom is not of this world. If my kingdom were of this world, my servants would have been fighting, that I might not be delivered over to the Jews. But my kingdom is not from the world. - John 18:36.
This deeply disappointed those who hoped He would overthrow the hated Roman occupiers. These reasons have convinced the audience enough to be on the side of Pharisees.
<OP: When did the Pharisees stop being afraid to arrest Jesus?
It is clear that Jesus ministered from about His age 30 to 33 1/2. During this time, He performed many miracles. The Gospel of John identifies seven of them, the last of which is the raising of Lazarus. By this time, some of the Pharisees believed, but others had been opposed. It was a sequence of events culminating in His arrest.
Here is one earlier event that references John 10:22-42.
“But Rabbi,” they said, “a short while ago the Jews there tried to stone you, and yet you are going back?” John 11:8
Thomas puts it this way when they are called to Bethany, a mere two miles from Jerusalem, about Lazarus.
Then Thomas (also known as Didymus[fn]) said to the rest of the disciples, “Let us also go, that we may die with him.” John 11:16
By this stage, there was opposition, even a failed, half-hearted attempt to stone Him. But it was this last recorded miracle that some decided it was time to end His ministry.
If we let him go on like this, everyone will believe in him, and then the Romans will come and take away both our temple and our nation.” So from that day on they plotted to take his life. John 11:48, 53
Lazarus was the final straw in the decision to arrest Jesus, but when exactly was this? We know times from what follows, which was the six days before the Passover (John 12:1), but as to precise timing before this, we do not know. We can, however, narrow it down to between the Feast of Dedication and six days before Passover when the Triumphal Entry took place on the fifth day before. There is also this mention.
When it was almost time for the Jewish Passover, many went up from the country to Jerusalem for their ceremonial cleansing before the Passover. John 11:55
This was after Lazarus' and before the six days.
Six days before the Passover, Jesus came to Bethany, where Lazarus lived, whom Jesus had raised from the dead. John 12:1
On the next day, Jesus made the Triumphal Entry. The Pharisees react again.
So the Pharisees said to one another, “See, this is getting us nowhere. Look how the whole world has gone after him!” John 12:19
Four days later on Thursday they would arrest Him before the Feast of Unleavened Bread.
So, when did the Pharisees stop being afraid to arrest Jesus? Once they realized the "whole world" was believing Him. They saw He was a threat to their prestige, power, and pocketbook. This was sometime between the "six days prior to Passover" and the "raising of Lazarus". Basically, even perhaps ironically, it may have been about the time of Purim, the commemoration of the deliverance of Israel from Haman in the last month of their year or about 30 days prior to Passover in the first month.