The penetration of Distributed Energy Resources (DERs) in distribution networks is expected to rise significantly due to the electrification of the transport sector, solar photo-voltaic installations and growth in small scale storage and generation. Also, several existing loads can be converted into Demand Response (DR) units and the total share of DR as a subset of DERs is projected to be large; especially flexibility from Thermostatically Controlled Loads (TCLs) is cast to provide a substantial part of the total DR-based flexibility in distribution networks. The increased participation of DERs in power system operations can pose an array of challenges to the Distribution System Operator (DSO), but may also be perceived as an opportunity to leverage the embedded flexibility to meet network constraints. This requires new operational methods as the distribution networks are currently passive, and with little possibility of active control which is mostly limited to voltage control based on historical data and crude forecasts. Optimizing low-voltage distribution feeders is complex due to the non-convex nature of power flows and leads to optimality and pricing issues in market-based settings. This is addressed through the use of convex relaxation techniques in this thesis. The power transfer through distribution networks will see drastic increases due to non-controllable Renewable Energy Source (RES) power in-feed (mostly PhotoVoltaic (PV) in urban distribution systems) and increased energy demand caused by Electric Vehicle (EV) charging loads and electrification of building heating and cooling. In order for the DSO to use TCL-based DR units to mitigate congestion issues caused by this increased energy transfer, the complex physical properties and limitations of these TCL-based DR units have to be incorporated into a market compatible framework. This thesis proposes a novel setting of using asymmetric block offers to embed the limitations of TCL-based DR into market compatible structures. This proposal coupled with the modeling of the network through convex conic programming leads to an efficient and cost-effective framework to use DR units and other DERs to mitigate congestion, and thus can decrease the cost of energy delivery and operation of the distribution network. One of the issues requiring higher amounts of available flexibility in the power system is the increasing penetration of renewable energy sources such as wind- and solar-based generation and the accompanying stochastic generation profiles. The very nature of renewable energy sources requires a large amount of flexibility due to forecast errors and intermittent generation. Organizing the flexibility properly in the day-ahead stage can help the steady and economic supply of energy. The growing need for flexibility has lead to the proposal of market designs that enable aggregated DERs to provide ancillary services to the Transmission System Operator (TSO), however this may pose a series of challenges to the DSO. At the same time proposals for market-based approaches to be employed by the DSO are receiving growing support and recognition. Coordinating the various proposed local markets with wholesale energy and TSO-level flexibility markets is a daunting task, as the size of the problem is immense and coordination requirements are complex. In the future there may be different market platforms available for DERs which they can use to increase their profits and the inherent economic incentives will aid their proliferation. In order to be efficient, those market-based methods have to be developed such that they provide a clear and transparent stimulus to all involved agents. Creating these market-based methods is also difficult due to the conflicting objectives of agents, and thus the complexity of sharing resources needs to be addressed by clearly defined hierarchical or distributed system organization. Taking on a hierarchical setup, this thesis proposes a construct to include coordination between local markets and wholesale in the scheduling stage. Another challenge that needs to be addressed by future market platforms and their coordination is that electricity markets are designed to be operated deterministically, i.e. they do not take into account the growing share of uncertain generation in the scheduling stages. This can lead to high costs in the balancing stage when the intermittent production of renewable energy sources becomes apparent. The incorporation of uncertainties in market-based settings may in the future lead to improved dispatch, however the ideal stochastic dispatch is not implemented in wholesale markets for several reasons. For example, it violates several market desirable properties such as revenue adequacy and cost recovery of agents. In order to improve the uncertainty aware dispatch in the scheduling stage, this thesis proposes a design that defines interface variables between the forward trading wholesale and DSO-level markets. This is shown to approximate the ideal stochastic dispatch. By finding optimal exchange characteristics of local DSO-level markets with wholesale energy markets the TSO-DSO coordination of DER flexibility is enabled in the scheduling stage and thus decreases the expected cost of operating the power system. For given values of these “coordination variables” the DSO-level markets are independently imposing caps on the quantity bids of DERs in the wholesale markets. The potential benefit of this pre-qualification on the social welfare of the overall system is quantified and compared to other coordination schemes. By coordinating local markets the uncertainty awareness of the day-ahead dispatch is increased, while maintaining the current sequential dispatch of scheduling and balancing, thus preserving the market desirable properties of deterministic markets. A further advantage of this optimal coordination scheme is the non-iterative solution strategy, i.e. the market operators do not need to exchange multiple messages.