How do I pass a variable from a custom module to its template file? I need to know the simplest method to pass variable from custom module to its template file. 
I have created the custom.module and placed custom.tpl.php in the module folder.

function custom_menu(){
  $items = array();

  $items['custom'] = array(
    'title' =&gt; t('custom!'),
    'page callback' =&gt; 'custom_page',
    'access arguments' =&gt; array('access content'),
    'type' =&gt; MENU_CALLBACK,
  );

  return $items;
}

function custom_page() {

    $setVar = 'this is custom module';
    return theme('custom', $setVar);    
}


i have added theme function but it is not working, can any one suggest me what is wrong with this code

function theme_custom($arg) {
  return $arg['output'];
}

function custom_theme() {
  return array(
    'Bluemarine' =&gt; array(
        'variables' =&gt; 'output',
        'template' =&gt; 'Bluemarine',
     ),
  );
}
Independently from the Drupal version for which you are writing the module, there are two errors in your code:

You define &quot;Bluemarine&quot; as theme function, but then you call theme('custom'), which would call the &quot;custom&quot; theme function
If you define &quot;custom&quot; as a theme function that uses a template file, then theme_custom() is never called

If you are writing code for Drupal 6, then the code should be similar to the following one. I take the assumption the name for the theme function is custom.
function custom_menu(){
  $items = array();

  $items['custom'] = array(
    'title' =&gt; t('custom!'),
    'page callback' =&gt; 'custom_page',
    'access arguments' =&gt; array('access content'),
    'type' =&gt; MENU_CALLBACK,
  );

  return $items;
}

function custom_theme() {
  return array(
    'custom' =&gt; array(
      'arguments' =&gt; array('output' =&gt; NULL),
      'template' =&gt; 'custom',
     ),
  );
}

function custom_page() {
    $output = 'This is a custom module';
    return theme('custom', $output);    
}

function theme_custom($output) {
}

The template file will have access to $output, and to any variables set in template_preprocess_custom(), if your module implements it.
For example, you could implement code similar to the following one:
function template_preprocess_custom(&amp;$variables) {
  if ($variables['output'] == 'This is a custom module') {
    $variables['append'] = ' and I wrote it myself.';
  }
}

With this code, the template file has access to $output and $append.
As example of theme function that uses a template file, you can look at theme_node(), which is defined in node_theme(), and that uses node.tpl.php as template file; the preprocess function implemented by the Node module for that theme function is template_preprocess_node().