A self consistent theory of a cigar shaped Bose-Einstein condensate (BEC) periodically modulated by a laser beam is presented. We show, both theoretically and numerically, that modulational instability/stability is the mechanism by which wavefunctions of soliton type can be generated in cigar shaped BEC subject to a 1D optical lattice. The theory explains why bright solitons can exist in BEC with positive scattering length and why condensate with negative scattering length can be stable and give rise to dark solitary pulses.