When the persecutions of Quraish became unbearable, the Holy Prophet Muhammad (Peace be upon him) migrated to Medina by the order of ALLAH Almighty. there were some people of Medina who had accepted Islam before the migration of our Holy Prophet Muhammad (Peace be upon him) to Medina. It was already decided that our Holy Prophet Muhammad (Peace be upon him) will be the leader of all the Muslims in Medina. As a leader, our Holy Prophet Muhammad (Peace be upon him) decided to establish peace in Medina so that he started to make agreements with other social communities. There were some Jew tribes residing in Medina. Our Holy Prophet Muhammad (Peace be upon him) made an agreement with them to defend Medina in case of an external attack on Medina. Initially the Jews agreed on it but later on, they refused to act upon this agreement. The agreement between Jews and Muslims is called the Charter of Medina.
There were three main tribes of the Jews who were causing more problems. These three tribes were Banu Qainuqa, Banu Quraiyzah, and Banu Nazir. The problem started when Banu Qainuqa started to fight with the Muslims in the time between the Battle of Badar and the Battle of Uhud. Our Holy Prophet Muhammad (Peace be upon him) tried to bring them on the terms but remained unsuccessful. After that, this tribe was expelled from Medina. This incident happened in the 2nd year of Hijri. A year later, another leader of Jews was expelled from Medina after found involved in various activities against the Muslims.
Banu Nazir, a tribe of Jews, involved in some activities seriously against the Muslims. They planned to kill (God forbidden) our Holy Prophet Muhammad (Peace be upon him) by rolling stone while he was standing at their stronghold. The Quraish also rose the Banu Nazir to stand against the Muslims. Our Holy Prophet Muhammad (Peace be upon him) took notice of all these activities and sent them a message to leave the Medina within ten days but they refused to do so and stayed remained in their fortresses. When they refused to accept the orders of our Holy Prophet Muhammad (Peace be upon him), the Muslim army was sent to siege them. After a few days of siege, they surrendered and exiled from Medina.
The tribe of Banu Qurayizah helped the Quraish openly at the battle of Trench. They helped the Quraish and guided them towards an alternate way from where they could cross the trench to enter in the area of Muslims. They continued their disturbances against the Muslims when the war was going on. Because of these activities, they were asked to leave Medina as punishment but they refused. So the Muslim army besieged their settlement. They also surrendered and punished according to their holy book, Old Testament. Their men were slain, women and children were made slaves and then sold and their properties were kept by the Muslims. This incident happened in the 5th year of Hijri.