CHESAPEAKE, Va. — The “riot” erupted suddenly on the Virginia-North Carolina border in a remote pocket of marshland and pine. “Go back to America!” the protesters shouted, hurling rubber rocks at a large plywood structure meant to be a United States consulate. “We don’t want you here! This is our country!”

Two dozen Marines in full riot gear marched out in formation, beat their batons against their shields and otherwise looked menacing. Within minutes they had pushed back the protesters — fellow Marines in jeans and hooded sweatshirts — in a display of crowd control skills. “It can be a long day if you’re a rioter,” said Staff Sgt. William M. Loushin, the instructor who staged the riot. “Once you actually start getting aggressive against a Marine, it never ends well.”

In the aftermath of the attack on the American diplomatic compound in Benghazi, Libya, the Pentagon sent two teams of elite, specially trained Marines to protect American Embassies in Libya and Yemen and would have deployed a third group to Sudan had not the government in Khartoum said no.

To demonstrate what those units — called F.A.S.T. Marines, for Fleet Antiterrorism Security Team — are trained to do, the Marines put on a show this week. At a training center on the edge of the Great Dismal Swamp, a clutch of reporters observed Marines repelling faux rioters, shooting down doors and clearing a supposed American embassy occupied by militants.