Christopher Cantwell, a self-described white nationalist who pepper-sprayed protesters during the demonstrations in Charlottesville, Va., last August, pleaded guilty to assault and battery on Friday and has been barred from Virginia for five years, prosecutors said.

Mr. Cantwell, 37, rose as a high-profile activist for the alt-right after being featured in a Vice News documentary about the demonstrations in Charlottesville. Some mocked him as the “crying Nazi” after he posted a video online in which he fights back tears while describing the aftermath of the demonstrations.

Now, he has been thrown out of Virginia after pleading guilty to two counts of assault and battery, and to violating the terms of his bond by referring to victims on social media and in a radio broadcast, prosecutors said in a statement. As part of the plea, Mr. Cantwell must not return to Virginia for five years.

Mr. Cantwell, who faced 12 months in jail for the crimes, had already served 107 days. The rest of his sentence was suspended. Mr. Cantwell was ordered to leave Virginia within eight hours of the delivery of his sentence on Friday, and not to make contact with the victims of his assault and battery crimes.