Solar flares observed in the 200-400 GHz radio domain may exhibit a slowly varying and time-extended component which follows a short (few minutes) impulsive phase and which lasts for a few tens of minutes to more than one hour. The few examples discussed in the literature indicate that such long-lasting submillimeter emission is most likely thermal bremsstrahlung. We present a detailed analysis of the time-extended phase of the 2003 October 27 (M6.7) flare, combining 1-345 GHz total-flux radio measurements with X-ray, EUV, and H{alpha} observations. We find that the time-extended radio emission is, as expected, radiated by thermal bremsstrahlung. Up to 230 GHz, it is entirely produced in the corona by hot and cool materials at 7-16 MK and 1-3 MK, respectively. At 345 GHz, there is an additional contribution from chromospheric material at a few 10^4 K. These results, which may also apply to other millimeter-submillimeter radio events, are not consistent with the expectations from standard semi-empirical models of the chromosphere and transition region during flares, which predict observable radio emission from the chromosphere at all frequencies where the corona is transparent.