The government divided when the duke of Palmela, who was its prime minister, called for new elections in October, hoping to unite the moderates, themselves divided into two factions. This sparked a reaction by the Septemberists, who were particularly strong in Porto, where they rebelled and set up a provisional junta. The duke of Saldanha, Palmela's replacement, attempted without success to suppress the Septemberist rebellion, which by now had spread beyond Porto to other areas. With the country on the brink of a second civil war, Queen Maria sought help from the Quadruple Alliance, consisting of Britain and France, as well as Spanish and Portuguese liberal elements. After the alliance imposed a naval blockade and sent troops, the Septemberists capitulated, Saldanha resigned, and a peace agreement was signed on June 29, 1847. Costa Cabral returned to power.