The 2D materials can be implemented in several functional devices for future optoelectronics and electronics applications. Remarkably, recent research on p-n diodes by stacking two-dimensional (2D) materials in heterostructures or homostructures (out of plane) has been studied extensively with novel designs that are impossible with conventional bulk semiconductor materials. However, the insight of a lateral p-n diode through a single nanoflake based on 2D material needs attention for facilitating the miniaturization of device architectures with efficient performance. Here, we have established a physical carrier type inversion technique to invert the polarity of MoTe2-based FETs with deep ultraviolet (DUV) doping in (oxygen) O2 and (nitrogen) N2 gas environments. A p-type MoTe2 nanoflake is transformed its polarity to n-type one when irradiated under DUV illumination in an N2 gaseous atmosphere and its returned to original one once irradiated in O2 gaseous environs. Further, Kelvin probe force microscopy (KPFM) measurements were employed to support our consequences where the value work function changed from ~ 4.8 and ~ 4.5 eV when p-type MoTe2 was inverted to n-type one, respectively. Also, using this approach, an in-plane homogeneous p-n junction was formed and achieved a diode rectifying ratio (If/Ir) up to ~3.8 × 104. This effective approach for carrier-type inversion may play an important role to advance the functional devices.