The fabrication of microstructures featuring freeform surfaces on semiconductor substrates confronts substantial obstacles due to their inherent material difficulties, including considerable hardness and brittleness, as well as geometric complexity. In this investigation, we leverage laser direct writing (LDW) combined with photoelectrochemical etching to achieve precise material removal from semiconductor surfaces. By conducting a series of experiments on a home-made LDW apparatus under varying conditions, we established a correlation between the etching depth and both the power intensity and motion speed of the laser spot. The analysis revealed that the etching depth exhibited linearly with the power intensity of the laser spot and inversely with the motion speed. Additionally, the half widths of the grooves maintained consistently within the range of 1–2 μm. By leveraging this methodology, we successfully fabricated a freeform micro-optical structure on an n-GaAs wafer by precisely adjusting the power intensity of the laser spot during scanning, thus demonstrating the feasibility for achieving nanoscale machining precision. This research underscores the promise of this technique in significantly advancing the fabrication processes of semiconductor devices.