As an aggregator involved in various renewable energy sources, energy storage systems, and loads, a virtual power plant (VPP) plays a key role as a prosumer. A VPP may enable itself to supply energy and ancillary services to the utility grid. This paper proposes a novel scheme for optimizing the operation and bidding strategy of VPPs. By scheduling the energy storage systems, demand response, and renewable energy sources, VPPs can join bidding markets to achieve maximum benefits. The potential uncertainties caused by renewable energy sources and the demand response are considered in a robust optimization model. Moreover, the robust VPP optimization accounts for its influence on markets to ensure optimal energy and reserve capacity bidding transactions in the day-ahead market and deals balancing in the real-time market. To demonstrate the performance of the proposed scheme, markets comprising various participants and managed by the system operator are implemented using mathematical models. The proposed method is evaluated using an illustrative system and the practical Taiwan power (Taipower) system with diverse uncertainty levels. The numerical results demonstrate the promising performance and the efficiency of the proposed method. The results also verify the effectiveness of the proposed method VPP with various combinations of renewable energy sources, energy storage systems, and loads.