Abstract Semiconductor junctions are of great significance for the development of electronic and optoelectronic devices. Here, controllable switching is demonstrated from a Schottky junction to a p–n junction in a partially ionic liquid‐gated MoS 2 device with two types of metal contacts. Excellent rectification behavior with a current on‐off ratio exceeding 10 6 is achieved in both Schottky and p–n junction modes. The formation of Schottky junction at the Pd electrode/MoS 2 contact and p–n junction at the p‐MoS 2 /n‐MoS 2 interface is revealed by spatially resolved photocurrent mappings. The switching between the two junctions under ionic gate modulation is correlated with the evolution of the energy band, further validated by the finite element simulation. The device exhibits excellent photodetection properties in the p – n junction mode, including an open circuit voltage up to 0.84 V, a responsivity of 0.24 A W −1 , a specific detectivity of 1.7 × 10 11 Jones, a response time of hundreds of microseconds and a linear dynamic range of up to 91 dB. The electric field control of such high‐performance Schottky and p – n junctions opens up fresh perspectives for studying the behavior of junction and the development of 2D electronic devices.