BERLIN — Chancellor Angela Merkel agreed on a coalition deal on Wednesday with her previous governing partners, including the Social Democrats, bringing her within striking distance of forming a new government after five months of political limbo. But the pact came at a steep price for her conservative party, which gave up the powerful Finance Ministry. Nearly half a million registered members of the center-left Social Democratic Party, many of whom oppose joining another administration led by Merkel, will get the final say; the deal is contingent on their approval in a postal vote that analysts say is too close to call.