BEIRUT, Lebanon — For years, the tiny, energy-rich country of Qatar has carved out a niche in the Arab world by trying to be everything to everyone. It housed an American military base and flooded the region’s airwaves with its influential media, all while keeping close ties to Iran and a wide selection of Islamist movements.

On Monday, five countries in the region announced that they were forcing Qatar to choose: Its powerful neighbor Saudi Arabia, Egypt and at least three other Arab nations severed all ties with the country, escalating their accusations that the Qatari monarchy supported Sunni Islamist terrorism and Iranian designs on the region.

Those Arab nations not only abruptly suspended diplomatic relations, as they have in the past, but also surprised many by cutting off land, air and sea travel to and from Qatar. All but Egypt, which has 250,000 people working there, ordered their citizens to leave Qatar.

The move created an immediate crisis for Qatar, whose only land border is with Saudi Arabia and which imports about 40 percent of its food from the Saudis. Residents said that people were stocking up on food and cash. And Qatari diplomats and citizens were scrambling to meet a 48-hour deadline to leave some Persian Gulf countries where they had been posted.