In-situ etching and selective epitaxy of AlxGa1-xAs by introducing a small amount of HCl gas were carried out by low-pressure metalorganic vapor phase epitaxy (MOVPE). A thermodynamic model based on the equilibrium state is presented to explain the etch and growth rates. These results show that the reaction between gas phase and surface is in quasi-equilibrium. An increase in material migration length on the surface caused by introducing HCl gas is thought to be the main reason for improvement in selective epitaxy.