Members of the Communication Workers Union (CWU) had earlier voted to go on strike, saying that the company had failed to adhere to a pension deal agreed last year, but the court ruled that that ballot was unlawful.

The CWU called the judgement an "utter outrage".

It had not given exact dates of when a strike could take place, but Royal Mail warned strikes could affect deliveries of postal votes in the election and Christmas parcels.

Royal Mail said the interim injunction means that no industrial action could take place before the union had balloted its members, and they had voted in favour and formally notified the company.

"We stand ready to engage with the CWU. If the union provides a binding commitment to remove the threat of strike action for the rest of 2019, we will enter into discussions without preconditions", said Shane O'Riordain, managing director of regulation and corporate affairs.

Royal Mail's shares rose more than 3% after the court ruling.

Amazon UK lists Royal Mail as one of its carriers.

The UK general election could have been affected by any strike, as postal votes accounted for around 18% of votes cast in the last election in 2017, according to figures from the Electoral Commission.

The most recent national postal strike took place in October 2009, when a massive backlog of undelivered letters forced Royal Mail to hire temporary staff.

Royal Mail said in its statement it wants to break the cycle of decline and grow its UK business, principally by expanding its parcel delivery network. UK letter volumes have declined by around 50 per cent since their peak in the early 2000s.

Royal Mail added it would continue to deliver on its existing plans without compulsory redundancies.

By Samantha Machado