Electrical energy is considered as one of the most effective factors in the development of every country. Because of population and economical growth in most countries, demand for electrical energy has increased significantly. In conventional vertically integrated power systems, uncertainty of actual prices of electrical energy and other ancillary services makes end users not think of optimal consumption. The important objectives such as improving reliability, facilitating economical operations, enhancing efficiency and promoting customer choices have led to move power systems from integrated industries to competitive markets. If there is no reasonable and fair structure for reactive and active power pricing in competitive electrical markets, investors will not have enough incentives to create active and reactive power sources. Therefore, independent system operator will have difficulty in supplying systems loads, ensuring appropriate level of voltage profile and other system constraints. Other objectives in competitive markets are reduction of generation costs, preservation of system constraints, increase of various participants' benefits and implementation of load management. In this thesis, after a brief introduction about competitive market and review of conventional methods of pricing, spot pricing based on short run marginal cost theory has been implemented. Short run marginal cost is defined as an incremental cost for producing additional power. In order to calculate marginal costs, an optimal power flow has been solved, that is real and reactive power dispatch so as to minimize total operating cost of utilities or maximize social welfare, subject to the operational constraints. The model is solved for various test systems using the high-level programming platform GAMS and nonlinear programming solver MINOS. Furthermore, the effects of different objective functions and network constraints on the marginal prices have been investigated in detail.