The physical and chemical properties of transition metal dichalcogenides can be effectively tuned by doping or alloying, which is essential for their practical applications. However, the microstructure evolutions and their effects on the physical properties induced by alloying from hetero-atoms with different outermost electronic structures are still unclear. Here, we synthesized Nb-substituted WS2 with various Nb concentrations showing unusual changes of optical behaviors and continuous electrical polarity reversal. The fully softened Raman mode, rapidly quenched photoluminescence, and severe electron scattering can be attributed to the combined effects of charge doping and lattice strain caused by atomic Nb doping. Three types of substitution modes of Nb atoms in the WS2 lattice were observed directly from atomic-resolution scanning transmission electron microscopy. Density functional theory calculations further confirm the role of lattice strain in the evolutions of optical and electrical characteristics. With increasing Nb concentration, n-type, ambipolar, and p-type field-effect transistors can be achieved, indicating the capacity of this doping method to engineer the properties of two-dimensional materials for future electronic applications.