Four British tourists who were seriously injured when a gunman opened fire at a Tunisian beach on Friday have been flown back to the UK by the Royal Air Force.

The four were transported on a specially-modified RAF C17 transport plane that left Brize Norton in Oxfordshire for Tunisia on Monday afternoon. Medic with experience bringing back injured service personnel from operations overseas were on board the aircraft, the BBC said.

The aircraft stopped at the Birmingham airport to drop one of the injured before continuing its flight to Brize Norton, BBC reported.

The Ministry of Defence said it is working with the National Health Service England to arrange "patients' onward moves once they're back in the UK to take each person to the best hospital in their area for their needs."

The attack saw a total of 38 people killed. So far up to 18 UK nationals have been confirmed dead but the toll is expected to rise to about 30, the BBC reported.

The government has said that all those hurt in the attack at a resort near Sousse on Friday will be brought home in the coming hours.

On 29 June, UK Prime Minister David Cameron told Parliament that the Royal Air Force will also "arrange directly the repatriation of all deceased British nationals whose families wish us to do so – as soon as the identification processes are complete."

The government is also working with tour operators to ensure that those who want to return to the UK can do so, with more than 20 special flights already ferrying hundreds back to Britain.