Putting values in a template file
The function you are looking for is theme_render_template(), which gets the filename of the template file to render, and an array of variables to pass to the template file.

In Drupal 6, it is called as in the following code.

 $messages = drupal_set_message();
  if (isset($messages['warning'])) {
    $title = count($messages['warning']) &gt; 1 ? 'The following update warnings should be carefully reviewed before continuing' : 'The following update warning should be carefully reviewed before continuing';
    $variables['messages'] .= '&lt;h4&gt;' . $title . ':&lt;/h4&gt;';
    $variables['messages'] .= theme('status_messages', 'warning');
  }

  // This was called as a theme hook (not template), so we need to
  // fix path_to_theme() for the template, to point at the actual
  // theme rather than system module as owner of the hook.
  global $theme_path;
  $theme_path = 'themes/garland';

  return theme_render_template('themes/garland/maintenance-page.tpl.php', $variables);


theme_render_template() is still present in Drupal 7, and Drupal 8.  

In Drupal 7, although, the function is only used from theme(). There isn't generally any reason to call the function directly; you can define a new theme function that uses a template file, and then call theme() as theme('theme_function', $array). (Replace 'theme_function' with the name of the theme function.)