The electronic properties of graphene zig-zag nanoribbons with electrostatic potentials along the edges are investigated. Using the Dirac-fermion approach, we calculate the energy spectrum of an infinitely long nanoribbon of finite width $w$, terminated by Dirichlet boundary conditions in the transverse direction. We show that a structured external potential that acts within the edge regions of the ribbon, can induce a spectral gap and thus switches the nanoribbon from metallic to insulating behavior. The basic mechanism of this effect is the selective influence of the external potentials on the spinorial wavefunctions that are topological in nature and localized along the boundary of the graphene nanoribbon. Within this single particle description, the maximal obtainable energy gap is $E_{rm max}propto pihbar v_{rm F}/w$, i.e., $approx 0.12$,eV for $w=$15,nm. The stability of the spectral gap against edge disorder and the effect of disorder on the two-terminal conductance is studied numerically within a tight-binding lattice model. We find that the energy gap persists as long as the applied external effective potential is larger than $simeq 0.55times W$, where $W$ is a measure of the disorder strength. We argue that there is a transport gap due to localization effects even in the absence of a spectral gap.