Active Queue Management (AQM) is an effective method used in Internet routers for congestion control, and to achieve a tradeoff between link utilization and delay. The de facto standard, the Random Early Detection (RED) AQM scheme, and most of its variants use average queue length as a congestion indicator to trigger packet dropping. This paper proposes a novel AQM algorithm, called Self-tuning Proportional and Integral RED (SPI-RED), as an extension of RED. SPI-RED is based on a Self-tuning Proportional and Integral controller, which not only considers the average queue length at the current time point, but also takes into consideration the past average queue lengths during a round-trip time. Furthermore, we give theoretical analysis of the system stability and give guidelines for the selection of feedback gains for the TCP/RED system to stabilize the average queue length at a desirable level. Extensive simulations have been conducted with ns2. The simulation results have demonstrated that the proposed SPI-RED algorithm outperforms the existing AQM schemes in terms of drop probability and stability.