We propose a self-tuning PI (Proportional-Integral) controller for an AQM (Active Queue Management) router supporting TCP traffic in the Internet. Classical control theory is applied in the controller design to meet the phase margin specification in the frequency domain. By assigning a proper interval of the phase margin, we can achieve good AQM performance by making the control system adapt to dramatic load changes. Our self-tuning PI controller self-tunes only when there is a great change in the network environment that would cause the phase margin of the AQM control system to drift outside the specified interval. Based on the knowledge of the queue size, our PI controller can regulate the TCP source window size by adjusting the packet drop probability, thus clamping the steady queue size around a desirable target buffer occupancy. We demonstrate by OPNET® simulations that with our self-tuning PI controller applied, the network exhibits a good transient behavior. A simple PID (Proportional-Integral-Derivative) controller design method is also provided.