Germany’s economy picked up speed in the final quarter of 2016 and the country’s budget surplus hit its highest mark since unification, the country’s statistics agency said Thursday, highlighting the strength of the economy ahead of elections later this year. Europe’s largest economy grew at a quarterly clip of 0.4%, or 1.7% in annualized terms, said the statistics agency Destatis, confirming its earlier estimates. Germany’s economy expanded at an annualized rate of 0.5% in the third quarter. The pickup was led by strong government spending and buoyant construction investments. Net trade, however, weighed on growth in the quarter, as imports rose more than exports. Investments in plant and machinery declined 0.1% from the previous quarter. Compared with the final quarter of 2015, Germany’s gross domestic product rose 1.7%, taking account of calendar effects. Robust economic activity also helped fill government coffers. The national budget surplus, which comprises the central government, the states, local administration and social security funds, rose to 23.7 billion euros ($25 billion) in 2016. It marks the highest surplus since 1991, the statistics body says. As a share of GDP, Germany’s national budget surplus in 2016 was 0.8%. Germany’s economy in 2016 performed well despite a series of shocks to confidence, including the U.K.’s vote to leave the European Union and terrorist attacks in Germany, France and Belgium. But solid business sentiment and a recent rise in manufacturing orders signal robust economic activity in the months ahead.