The two companies' assessments of creditworthiness can influence how much a country has to pay to borrow in international debt markets.

S&P rates the United Kingdom at AA with a stable outlook, having downgraded the rating by an unprecedented two notches from the highest triple-A grade in the days after the 2016 Brexit vote.

"Our ratings on the UK and our forecasts do not incorporate a rapid deterioration in the UK's terms of access to the EU. If this assumption does not hold true, downward pressure could build on the UK's sovereign ratings," two of its top analysts said in a report.

Britain will formally leave the EU at the stroke of midnight Brussels time on Friday.

It then has until the end of the year — a transition period during which it will remain an EU member in all but name — to hammer out an agreement on trade and other issues including security, energy, transport links, fishing rights and data flow.

Without comprehensive and permanent trade agreements, companies may continue to shy away from large-scale investments in the United Kingdom, S&P said.

"Sluggish investment, in turn, implies that the UK's trend of sub-1.8% headline GDP growth could become ingrained," the ratings agency added.

A separate report from Moody's, which rates the United Kingdom Aa2, in line with S&P's rating but with a negative outlook, had a similar message.

"A looser economic relationship would result in structurally weaker economic fundamentals for the UK, and to a lesser extent the EU. This structural weakness is a clear credit negative for the UK sovereign and related issuers," it said.

In contrast, a trade deal that allowed quota-free and tariff-free trade in goods would limit any negative effects.

That would be beneficial for the automotive, chemicals, food and agriculture sectors, and also machinery sectors, which account for the largest trade flows in goods between the UK and the EU. It would also limit disruption to the retail sector.

"The medium-term growth outlook for the UK depends very much on what kind of future trade relationship is reached with the EU," Moody's said.

By Marc Jones