LONDON (Reuters) - Britain’s economy shrank for the first time since 2012 in the second quarter, a severe hangover from a pre-Brexit stockpiling boost and one that bodes poorly as Prime Minister Boris Johnson gears up to leave the EU in October.

Sterling slid to a new 31-month low against the dollar after data showed output in the world’s fifth-largest economy fell by 0.2% in the three months to June compared with the previous quarter, below all forecasts in a Reuters poll of economists that had pointed to a flat reading.

With Johnson’s government committed to leaving the European Union on Oct. 31, regardless of whether he can secure a transition deal to avoid trade disruption, the outlook for the remainder of 2019 is uncertain.

The world economy has also slowed due to the trade conflict between the United States and China.

Year-on-year economic growth slid to 1.2% from 1.8% in the first quarter, Britain’s Office for National Statistics said, its weakest since the start of 2018.

“There is ... little doubt that the economy is stalling, regardless of the volatility in the data,” PwC senior economist Mike Jakeman said.

(GRAPHIC - British economic output declines for 1st time since 2012: tmsnrt.rs/2YzMP00)

He said the Brexit crisis and the uncertain global outlook left Britain’s economy on a “knife-edge” for the third quarter.

Finance minister Sajid Javid told the BBC he was not expecting a recession “at all”. He added that the figures - which none of the 51 economists polled by Reuters predicted - “were not a surprise in any way”.

Annual growth in June alone was the weakest since August 2013 at 1.0%.

DOVISH DATA

The Bank of England last week predicted that growth will pick up to a quarterly rate of 0.3% during the current quarter, and that growth for the year as a whole will drop to 1.3%.

But it also warned of a 1-in-3 chance that output in annual terms will contract in the coming quarters, even if Britain leaves the European Union on reasonable terms.

Slideshow ( 3 images )

“The Bank of England has retained its tightening bias but any continued economic weakness will mean policymakers are likely to take an increasingly dovish stance,” Chris Williamson, chief business economist at IHS Markit, said.

Previous data had shown a collapse in factory output in April as car manufacturers brought forward their annual summer shutdowns to follow the original March 29 Brexit deadline that was postponed to Oct. 31.

But June manufacturing data was also unexpectedly poor and factory output for the quarter contracted at the fastest rate since early 2009, when Britain was mired in recession.

Slideshow ( 3 images )

Private-sector business surveys have shown the manufacturing and construction sectors both suffered falling activity in July, while the larger services sector eked out only modest growth.

Nonetheless, most economists expect some improvement in the third quarter - which would avoid Britain meeting the technical definition of a recession, which is two consecutive quarters of negative growth.

“Consumers have cash in their pockets - wage growth is at an 11-year high (and) surveys point to further increases in employment,” Pantheon Macroeconomics’s Samuel Tombs said.

“In addition, growth in government spending should retain its current momentum, given the new government’s zeal for fiscal loosening,” he added.

Javid said late on Thursday that he would set out spending plans for next year in September.

Britain’s economy has slowed since June 2016’s vote to leave the EU, with annual growth rates dropping from more than 2% before the referendum to expand by 1.4% last year.

Friday’s data showed business investment contracted 0.5% in the second quarter of the year versus economists’ expectations of a 0.3% fall.

Household spending, which has been much more resilient than business investment, due to falling unemployment and rising wages, rose 0.5% on the quarter.

Trade figures and its contribution to GDP were distorted erratic flows of non-monetary gold and also showed the effect of businesses building up fewer stocks than in the first quarter of the year when they were readying for Brexit.