Germany's trade surplus shrank for the first time since 2009 last year as imports outpaced exports in Europe's booming top economy, giving Berlin ammunition to ease criticism of its huge trade gap with other countries.

The country's trade surplus unexpectedly fell to 245 billion euros ($300 billion) from a record 249 billion in 2016, figures from federal statistics authority Destatis showed.

Germany routinely comes under fire over its massive trade surplus, with partners from Paris to Washington urging the government to address the chronic imbalance by doing more to encourage consumption at home, indirectly boosting other nations.

In what may go some way to silencing those complaints, Destatis said imports soared by 8.3 percent last year to an all-time high of 1.03 trillion euros.

It marks the first time German imports have breached the psychologically significant trillion-euro barrier, and comes as the economy is humming, wages are high and unemployment is lower than ever.

But Germany's exporters are also on a roll, benefiting from a robust global recovery.

Exports shot up 6.3 percent to 1.3 trillion euros last year -- another fresh record.

"It's the typical German success story when it comes to exports," analyst Carsten Brzeski of ING Diba bank told AFP.

The latest snapshot of the country's trade balance could make it easier for German policymakers to counter criticism of its massive surplus, he said.

"They can say: this is what you have been arguing for," said Brzeski.

But insatiable appetite for German goods abroad means the irritation is likely to persist.

"For the critics, the reduction is far too little," he said. "I expect the country will still have extremely high trade and current account surpluses in 2018."

- 'Unfair' -

The 2017 figures showed that German demand was strongest for goods made inside the European Union, but there was also a nine-percent jump in imports from the rest of the world, including the United States.

Most of Germany's goods sold abroad meanwhile were bought by fellow EU member states, accounting for some 750 billion euros, up 6.3 percent on 2016.

Looking ahead, observers say the recent strength of the euro may put the brakes on exports in coming months, as a stronger currency makes German goods more expensive abroad.

But Brzeski said exporters are unlikely to suffer much.

"German exports have always proven to be resistant to a strong euro," he said.

He added however that the euro's rise against the dollar in particular means Germany may "feel some negative impact" in its bilateral trade with the US.

US President Donald Trump has been among the most vocal opponents of Germany's surpluses, calling his country's trade deficit with Germany "unfair" and wondering aloud why there are so many German cars on American roads.

But he is far from alone.

European partners and global institutions like the International Monetary Fund have long urged the German government to spend and invest more to push up demand and boost growth in other regions.

German officials argue that the trade surplus reflects the strength of the "made in Germany" brand and insist there is little they can do to influence the spending of companies and individuals.

But those arguments have done little to stop the grumbling. Just last month, IMF chief Lagarde called on Berlin to relax its cherished budgetary discipline and help "reduce global imbalances".

- Merkel's spending plans -

Those pleas have perhaps not fallen on deaf ears.

The coalition pact unveiled by Chancellor Angela Merkel's would-be new government on Wednesday reaffirmed Berlin's commitment to a balanced budget, but also pledged billions of euros in extra spending on education, childcare and internet infrastructure.

Critics will also be cheered by rising salaries in Europe's powerhouse, with Destatis announcing that real earnings grew 0.8 percent in 2017.

The country's most powerful union IG Metall, which represents nearly four million workers, this week won a 4.3-percent pay increase from employers, setting the tone for similar wage hikes in other industries.