In the three months to August, output fell by 0.8%, the biggest such decline since March 2013.
Meanwhile, the UK trade deficit was £3.3bn in August, a narrowing of £1.2bn from July, it said.
But the deficit was larger than expected and is set to weigh on growth, the ONS added.
An ONS official said the weak figures for construction in August may have been linked to wet weather during the month.
Housebuilding fell by 3% from July and output in other parts of the sector also contracted for the first across-the-board decline since 2010.
The trade figures showed the UK's deficit in its trade in goods narrowed to £11.1bn in August compared with £12.2bn in July, although some analysts had expected it to shrink further.
The deficit of £11.1bn on goods was partly offset by a £7.9bn surplus on services. Exports increased by £0.8bn, boosted by cars.
The combined goods deficit for July and August is already twice that of the previous quarter, and is likely to have a negative effect on overall GDP growth.
The UK's economy grew by 0.7% in the second quarter of the year, but Howard Archer of IHS Global Insight said overall growth prospects for the third quarter had received a "double blow" from the construction and trade data, which was "seriously bad news overall".
"Overall, the data reinforce our belief that GDP growth is likely be no better than 0.5% quarter-on-quarter in the third quarter, and there is now a significant risk that it could have been weaker still."
David Kern, chief economist of the British Chambers of Commerce, said: "The large trade deficit remains a major national problem. Greater efforts are needed to support our exporters and to secure a long-term improvement in our trading position."

The Care Quality Commission (CQC) visited Haven Nursing Home in September in response to concerns raised by staff and relatives.
It found the home, which has a history of non-compliance with regulations, did not have a CQC registered manager.
A new manager who took over last month said safety and comfort had been improved.
Inspectors found that staff were kind and tried their best to provide care.
It also said relatives and friends were allowed to visit at any time of day.
Updates on this story and more from Coventry and Warwickshire.
The home can care for up to 70 older people, and mainly looks after people with dementia.
Inspectors found:
The home will remain in special measures and be kept under review.
Maurice Fordy, manager of Haven Nursing Home since October 5, said: "The report refers to a situation as it was prior to September of this year.
"We have worked closely with the CQC and the local authority to ensure the improved safety and comfort of residents at the nursing home.
"The manager from that time has been replaced and I am pleased with the improvements that we have made so far."
Construction output fell 4.3% in August, its sharpest drop since late 2012, the Office for National Statistics (ONS) has said.
[NEXT_CONCEPT]
A Coventry nursing home has been rated as "inadequate" after inspectors found it did not have enough staff.