After the Almohad defeat at the Battle of Las Navas de Tolosa, the empire disintegrated and fractured in smaller kingdoms called taifas.
By 1228, an indigenous Valencian-Muslim rebellion led by Ibn Hud, gained enough support to take the city of Madina Mursiyya and to dominate the regions of Orihuela, Dénia, Gandia, Xàtiva, and Al-Yazirat Suquar.
Abū Zayd fled Valencia and headed north while Zayyan triumphantly entered the city in the winter of 1229 without proclaiming himself king.
From Madina Mursiyya, the anti-Almohad rebel, Ibn Hud, laid siege to Valencia, putting pressure on Zayyan, who abandoned the city.
[2] On a document dated to 28 October issued in Lérida, James I proclaimed that once the city of Valencia was conquered, he would donate to its church, saying: "apud Montesonum in curia generali quam convocavimus pro facienda exercitus contra mauros".
In further preparation for Valencian life after the conquest, James I decreed that the provincial master for the Order of the Temple would have the power to mint coinage in its territories.
He gathered his forces at Monzón on 28 October 1236 where he gained approval from Pope Gregory IX to name the conquest an official Crusade by order of Papal Bull on 2 February 1237.
After encamping in Montpellier from the end of 1236 through the beginnings of 1237, the army concentrated on Teruel and followed the Palancia River, taking La Vall d'Uixó, Nules, and Almenara.
After two months, the defensive works were ready and the castle was occupied by a garrison of 100 knights and many more peasants commanded by Bernat Guillem I d'Entença, a relative of the king.
According to the Muslim historian Ahmed Mohammed al-Maqqari, the attack occurred shortly after James I had left El Puig for Huesca.
At the council of magnates, Blasco I of Alagonia, speaking on behalf of many other barons, voiced that it would be better to evacuate El Puig and temporarily abandon the gains made during that portion of the campaign.
In front of all the nobles present and the representatives of the military orders, the king knighted Guillem and pronounced him the heir to all the titles and lands of his father.
On the contrary, once knowing that the king was en route, a large portion of the garrison at Puig met secretly and agreed to abandon their position.