BEIRUT—As Iran grapples with one of the worst coronavirus outbreaks world-wide, its neighbors are struggling to stem the flow of people and goods across porous borders as they attempt to insulate themselves against the epidemic.

The virus has been transmitted from Iran to around a dozen countries, including neighboring Iraq, Pakistan and Afghanistan. These countries are taking measures such as suspending flights and banning Iranians from visiting to prevent the outbreak spreading further and challenging their fragile health...