Greece and its international lenders reached a multi-billion-euro bailout agreement on Tuesday after marathon talks through the night, officials said, raising hopes aid can be disbursed in time for a major debt repayment falling due in days.

After an 23-hour session that began on Monday afternoon, exhausted Greek officials emerged in a central Athens hotel to announce the two sides had agreed details of the deal though a couple of minor issues remained to be ironed out.

“Finally, we have white smoke,” a finance ministry official said. “An agreement has been reached. Some minor details are being discussed right now.”

The pact is expected to be worth up to 86 billion euros ($94.75 billion) in fresh loans for debt-ridden Greece, but there was no immediate confirmation of its size.

Greek officials have said they expect the accord to be ratified by parliament on Wednesday or Thursday and then be vetted by euro zone finance ministers on Friday. This would pave the way to aid disbursements by August 20, when a 3.2 billion euro debt payment is due to the European Central Bank.

An agreement would close a painful chapter of aid talks for Greece, which fought against austerity terms demanded by creditors for much of the year before relenting under the threat of being bounced out of the euro zone.

Still, popular misgivings run deep in Germany, the euro zone country that has contributed most to Greece’s two bailouts since 2010, about funnelling yet more money to Athens.

During talks which dragged through the night, the sides agreed on final fiscal targets that should govern the bailout effort, aiming for a primary budget surplus — which excludes interest payments –from 2016, a government official said.

Adapted from an earlier baseline scenario, the targets foresee a primary budget deficit of 0.25% of gross domestic product in 2015, a 0.5% surplus from 2016, 1.75% in 2017, and 3.5% in 2018, the official said.

Dealing with a mountain of non-performing loans (NPLs) in the banking sector were among the sticking points in talks. Athens wanted to set up a “bad bank” to take on the problem loans, while creditors want NPLs bundled and sold to distressed debt funds. It was not immediately clear how that was resolved.

Officials had also argued over how to set up a sovereign wealth fund in Greece designed to raise 50 billion euros from privatisations, three-quarters of which would be used to recapitalise banks and to reduce the debt.

Both sides had agreed to deregulate Greece’s natural gas market, finance ministry sources said.