ISTANBUL (AP) — The surprising margin of victory for President Recep Tayyip Erdogan's party in parliamentary elections marks a remarkable turnaround and puts him firmly in control of Turkish politics. Among the challenges Erdogan will have to navigate are renewed threats of civil war in the Kurdish southeast as well as a wave of Syrian refugees pouring across Turkey to Europe and major instability across its borders as the Islamic State group wages battle in Iraq and Syria. The Justice and Development Party, or AKP, came roaring back just five months after losing its majority in a June parliamentary election, nearly doubling its closest rival in support and improving its results by millions of votes and about nine percentage points. Since June, Turkey has seen the outbreak of its worst violence in years. A once promising peace process with the Kurdistan Workers' Party, or PKK, has gone off the rails and two massive suicide bombings at recent pro-Kurdish gatherings killed some 130 people. The two parties, despite coming from opposite ends of the political spectrum, flirted with a deal that would expand rights and autonomy for Kurds in exchange for agreeing to strengthen the president's powers. In the second campaign, Erdogan castigated HDP as the political arm of the PKK, which Turkey and most Western countries consider a terrorist organization.