Water and energy systems are closely linked. Energy is needed in most stages of water usage, while water is needed to extract and process energy resources and generate electric power. However, policy goals associated with providing adequate water and energy supplies are often in opposition, causing conflicts over these two resources. This problem will be aggravated by population growth, rising living standards and climate change, highlighting the importance of developing integrated assessment and solutions. In this context, this study focused on the interaction between water and electric energy (or power) systems, with the goal of identifying a method that could be used to assess the broader spatio-temporal interactions between water and energy systems. The proposed method is to include water users and power producers into a joint optimization problem that minimizes the cost of power production and maximizes the benefits of water allocation. This approach turns the multiobjective problem of water and power system management into a single objective one: net costs minimization. The economic value of water is calculated as a function of the state of the system, and this value is used to determine optimal allocations for each time step of the planning horizon. The physical linkages between the two systems are described as constraints in the optimization problem, and the problem is solved using stochastic dynamic programming or stochastic dual dynamic programming. The method was implemented on the Iberian Peninsula to assess some of the interactions between the water and power system. The impact of climate change on the current Iberian power system was assessed. It was found that expected precipitation reductions will reduce runoff, decrease hydropower production, and increase irrigation water demand; whereas expected temperature increases will modify seasonal power demand patterns. The proposed approach was also used to determine hydropower benefits in a coupled water-power system, and the results compared with traditional methods that represent hydropower benefits through exogenous prices. It was found that representing hydropower benefits through a constant price can be inadequate because it does not reflect the seasonality in power demand and water inflows, which affect the availability, and therefore value, of hydropower. Monthly prices were able to represent seasonality but resulted in unrealistic operation rules, such as emptying the reservoir during the month with the highest price, which can only be avoided through the inclusion of additional constraints. In contrast, including a simple representation of the power market into a hydro-economic model resulted in more realistic reservoir operation policies that adapted to changing inflow conditions. The effects of spatial aggregation on the analysis of water-power systems were evaluated by comparing results from an aggregated and a partially disaggregated model. The aggregated model, where all reservoirs were represented as a single equivalent energy reservoir, provided valuable insights into the management of water and power systems, but only at the Peninsula scale. The disaggregated model revealed that optimal allocations were achieved by managing water resources differently in each river basin according to local inflow, storage capacity, hydropower productivity, and irrigation demand and productivity. This highlights the importance of considering spatial differences in this type of analysis. The method was successfully used to assess linkages between the water and the power systems of the Iberian Peninsula. The framework is flexible and can potentially be used to model more aspects of the water-energy nexus, for instance: the energy requirements of the transport sector and the impact of biofuels on agriculture; the impact of reduced river discharge on cooling of thermal power plants; or the impact of carbon capture and storage on water resources. The increasing pressure of population growth, rising living standards, and climate change on water, energy, land, and climate systems will increase the need for integrated methods and models to assess the linkages between these systems. The methodological framework proposed here is a step forward in the development of these integrated tools.