* Both exports and imports hit all-time highs in 2017
* Vibrant domestic demand sucks in more imports
* Shrinking trade surplus good news for Merkel
* Data helps defuse criticism from Trump and others (Adds more trade data, BGA trade body on stronger euro)
BERLIN, Feb 8 (Reuters) - Germany's trade surplus fell last year for the first time since 2009, data showed on Thursday, in a further sign that vibrant domestic demand is sucking in more imports and slowly re-balancing the country's export-oriented economy.
Chancellor Angela Merkel has come in for criticism from the European Commission and U.S. President Donald Trump for Germany's large trade surplus, while scepticism towards free trade is mounting in some poorer euro zone countries.
International Monetary Fund chief Christine Lagarde has also urged Berlin to increase domestic spending and boost imports, warning that ballooning current account surpluses in countries such as Germany are partly responsible for the rise of protectionism elsewhere.
"The improvement of the trade balance is driven by imports and not by exports," Dekabank analyst Andreas Scheuerle said. "This means we don't have to put the brakes on exports. This is a win-win situation."
In 2017, Germany's trade surplus shrank to 244.9 billion euros ($300.9 billion) from its record high of 248.9 billion euros in the previous year, according to data from the Federal Statistics Office. It was the first decline since 2009.
The wider current account surplus, which measures the flow of goods, services and investments, edged down to 257.1 billion euros from 259.3 billion euros the previous year.
"This will please U.S. President Donald Trump, for whom the German export surplus has always been a thorn in his side," said Christiane von Berg from BayernLB.
Exports rose by 6.3 percent in 2017 to a record high of 1.28 trillion euros, the data showed. But this was outpaced by an 8.3 percent increase in imports to 1.03 trillion euros, also an all-time high.
"Demand for German products clearly picked up on all continents. But we're particularly pleased about the economic upturn in Europe," said Holger Bingmann, head of the BGA trade association.
The recent appreciation of the euro has so far hardly affected German export flows, Bingmann added.
The German government expects the consumer-led upswing in Europe's largest economy to continue this year, forecasting 2.4 percent growth for 2018 after 2.2 percent in the previous year.
To secure a fourth term as chancellor, Merkel on Wednesday handed her Social Democrat coalition partners control of the finance ministry, giving them licence to spend a record budget surplus, and embracing their demands for European reform.
The agreed hike in additional state spending is likely to boost domestic demand even further and help to reduce the still-large trade surplus in coming years.
A government report said last month import growth was expected to continue to outpace export growth in 2018.
In December alone, seasonally adjusted exports rose by 0.3 percent on the month while imports rose by 1.4 percent, the data from the statistics office showed.
The exports figure beat expectations of a 1.0 percent fall while imports also came in stronger than the forecasted 0.5 percent decrease.
The seasonally adjusted trade surplus in December narrowed to 21.4 billion euros. This was smaller than the Reuters consensus forecast of a surplus of 21.7 billion euros.
($1 = 0.8140 euros) (Reporting by Michael Nienaber; Editing by Paul Carrel and Andrew Roche)