The man shouted slurs including “proud to be British” and “go back to where you came from” outside Carlisle’s Brook Street mosque.
He pleaded guilty to racially aggravated harassment on 30 November at the city’s Crown Court on Tuesday.
Judge Paul Batty told the man that racism in any form would not be tolerated and sentenced him to six months prison.