LESOVO, Bulgaria — Less than two decades after the painstaking removal of a massive border fence designed to keep people in, Bulgarian authorities are just as painstakingly building a new fence along the rugged Turkish border, this time to keep people out.

Faced with a surge of refugees from the Middle East and North Africa — and the risk that they include jihadis intent on terrorist attacks — Europe is bolstering its defenses on many fronts, including this formerly Communist country, which little more than a quarter-century ago was more concerned with stanching the outbound flow of its own citizens to freedom. For the past 16 months, Bulgaria has been carrying out a plan that would sound familiar to anyone along the United States-Mexico frontier: more border officers, new surveillance equipment and the first 20-mile section of its border fence, which was finished in September.

The hardening of the Bulgaria-Turkey border is one very visible manifestation of the agitation across the continent about the economic, social and political ramifications of the surge in immigration. With warmer weather fast approaching and more refugees likely to be on the move, nations along Europe’s southern tier are beefing up border staffing, adding sensors and other technical barriers, expanding refugee facilities, and building walls.

More than 200,000 refugees are known to have penetrated Europe’s land and sea borders last year, not including those who were able to sneak through undetected.