The economy, however, remains deep in recession and unemployment at a record high.

Deputy Finance Minister Christos Staikouras said preliminary figures show the state budget had a primary surplus — which excludes interest payments on debt — of 2.6 billion ($3.5 billion) euros for the January-July period.

That is a far better result than its target of a 3.1 billion euro ($4.2 billion) deficit, and marks the first time the government has logged a significant primary surplus.

The actual deficit, including interest payments, came in at 1.9 billion euros, also better than the targeted 7.5 billion euros deficit, the finance ministry's figures showed. In the same period last year, the country posted a 13.2 billion-euro deficit.

The deficit now stands at 1 percent of gross domestic product, from 6.8 percent in the same period last year, Staikouras said.

Greece has depended on international rescue loans since 2010. In return, it has pledged to overhaul its economy, and has imposed repeated waves of austerity measures. It has reduced spending across the board, including cuts to state salaries and pensions, and increased taxes.

The improvements in the budget this year were achieved by a combination of cutting spending and increased revenues in some taxes.

It was also helped by a one-off payment of about 1.5 billion euros from other European central banks. The money came from Greek government bonds that the European Central Bank had bought earlier during the financial crisis. Rather than keep the money accrued on the bonds, the ECB handed it down to the 17 national central banks in the eurozone, who in turn gave it to the Greek government.

Despite the improvements, the economy remains in trouble.

Unemployment hit a record of 27.6 percent in May. Almost two-thirds of young people are without a job. The country is mired in the sixth year of a deep recession that has seen the economy shrink by about a quarter, though the latest figures suggested a slight easing in the drop.

The statistical authority on Monday said economic output shrank by 4.6 percent in the second quarter of 2013, compared with the same three months last year. That is less than the 5.6 percent it contracted in the first quarter of the year.