We have demonstrated the ability to fabricate stress-free micromechanical cantilever beams by selective etching of silicon p-n structures in HF solutions utilizing a photoassisted electrochemical process. A particular novelty of this technique is that n or p regions of a p-n structure may be selectively etched at controlled rates by appropriate choice of cell bias, p-n junction bias, and illumination intensity. p-Si is selectively etched by either one of two ways. Illumination of the p-n junction serves to bias the p-layer anodically relative to the n-substrate, resulting in etch rates of up to 0.6 mu m/min. Alternatively, p-Si etch rates up to 10 mu m/min are attained without illumination by short circuiting the p-n junction and anodically biasing the n-Si substrate. n-Si, on the other hand, is selectively etched at rates up to 10 mu m/min by illuminating and reverse biasing the p-n junction, driving the p-layer cathodic. At etch rates below approximately 1 mu m/min, porous silicon layers form, which can be subsequently removed with chemical etchants. These processes are characterized by high-resolution etch-stops with smooth surfaces, rendering them potentially attractive for micromachining purposes. The effects of key variables, including doping type, cell bias, p-n junction bias, and illumination intensity, on etch rate, selectivity, and surface finish are discussed.