Britain has advised its nationals in Tunisia to leave the country, warning local authorities could not provide "adequate protection" after last month's beach massacre that left 30 Britons dead.

The Foreign Office said on Thursday it was advising against all but essential travel to the North African country.

It said that British tourists in Tunisia should contact their travel agents, who would arrange flights to bring them home. Independent travelers were advised to return on scheduled commercial flights.

"Although we have had good co-operation from the Tunisian government, including putting in place additional security measures, the intelligence and threat picture has developed considerably, reinforcing our view that a further terrorist attack is highly likely," the foreign office said on Thursday.

"On balance, we do not believe the mitigation measures in place provide adequate protection for British tourists in Tunisia at the present time and we have therefore changed our travel advice accordingly."

The warning comes almost a fortnight after a Tunisian student went on a rampage at a popular beach resort, killing 38 foreign tourists.

The Foreign Office had previously advised against travel to certain hotspots, including near the borders with Algeria and Libya, but now urged Britons to keep away from the entire country unless they had essential business.

Tunisian President Beji Caid Essebsi on Saturday decreed a state of emergency in the north African country for 30 days, and Prime Minister Habib Essid said on Wednesday that the government feared more attacks.

"We would not have felt obliged to decree the state of emergency if we were not convinced that our country was facing numerous terrorist plans to destabilise the country," he told parliament.

Tunisia stepped up security around tourist sites in the wake of the June 26 shootings, the second attack on tourists there in three months.

Both were claimed by the Islamic State of Iraq and the Levant group (ISIL). 

The Foreign Office said: "The Tunisian authorities have increased their security measures but have also acknowledged the limitations in their ability to counter the current terrorist threat."

About 20,000 British tourists were on package holidays in Tunisia at the time of the attack, according to ABTA, the country's largest travel association. 

Thousands chose to return home after the shooting.