The thermohaline circulation in an idealized marginal sea is studied using both numerical and analytical models. The circulation is forced by repeating an annual cycle of cooling in the interior of the marginal sea for 2 months and turning off the surface forcing for 10 months. The marginal sea is connected to an open ocean through a narrow strait, thus providing a means to equilibrate the cooling within the marginal sea by exchange with the open ocean. The resulting upper ocean circulation consists of a warm boundary current that flows into the marginal sea through the strait that is gradually eroded as it circulates cyclonically around the marginal sea. The interior of the marginal sea is relatively cold and has a closed cyclonic circulation. The mean downwelling is concentrated within a narrow boundary layer that, for a Laplacian parameterization of subgridscale mixing of density and momentum, has a width of Ldσ1/2 and an along-boundary decay scale of Ldσ3/2E-1, where Ld is the internal deformation radius, σ is the horizontal Prandtl number, and E is a horizontal Ekman number. The net downwelling outside of this boundary layer is very small at all times. The heat balance near the boundary is between vertical advection and horizontal diffusion at scales smaller than the mesoscale. In the interior, cooling by surface forcing and vertical convection is balanced by horizontal eddy fluxes. For some configurations, these eddy fluxes are characterized by very low frequency oscillations (periods of 1-10 years) in the gyre-scale circulation. One of the main results of this study is that the downwelling in the marginal sea is concentrated near the boundaries and depends on details of the mixing of momentum and density on scales smaller than the mesoscale. The basin-scale stratification and circulation also depend on how momentum and density mix within this boundary layer. This suggests that, in addition to resolving the mesoscale eddy field, improved parameterizations of submesoscale mixing are needed to properly represent the circulation in marginal seas and the downwelling limb of the thermohaline circulation.