The party of Spain’s premier has clinched a controversial deal with Catalan separatists that will enable him to form a government and remain in power, a source told AFP on Thursday. In exchange for their support, the separatists will get passage of a bill that will grant amnesty to Catalans being prosecuted for their involvement in the failed attempt to secede from the rest of Spain in 2017. The proposed bill has sparked several days of tense protests in the country this week, with thousands rallying against it in the capital Madrid. Prime Minister Pedro Sanchez’s Socialists finished second in the July 23 parliamentary elections and he has until November 27 to cobble together a working coalition, or face fresh elections. Sanchez needs the support of Catalan independence parties, and has accepted their demands to offer amnesty to all those being pursued for their role in a failed secession attempt in 2017. In response, conservative opposition parties and members of Spain’s judiciary have stepped up criticism, with some accusing Sanchez of corruption and abandoning the rule of law. A source with knowledge of the negotiations between the Socialists and the Catalan parties said on Thursday that agreement had been clinched and that details would be presented later in the day in Brussels. Brussels is currently the base of Catalan separatist leader Carles Puigdemont, who left Spain for Belgium following the failed secession bid to avoid prosecution.