page which display only $content (no header,footer,sidebars) I wanted to show a page which displays only $content. I successfully got the output when I used this code in template.php inside my theme.
function THEMENAME_preprocess_page(&amp;$vars) {   
  if (isset($_GET['ajax']) &amp;&amp; $_GET['ajax'] == '1') {
    $vars['template_file'] = 'page-ajax';
  } 
}

In page-ajax.tpl.php, I used the following code.
&lt;?php
  echo $content
?&gt;

Is there anyway to achieve the same thing using a custom module?
update
I think you all misunderstood my question, i want to override page.tpl with only $content, Not how to create a tpl using hook_theme!
Currently i have used the same code in my module, but the problem is i have to manually copy page-ajax.tpl to my active theme directory. You can refer the module i created http://drupal.org/project/ajax_links_api
Drupal works its way down a function call stack to find and use hooks defined in other places. So, in much the same way that THEMENAME_preprocess_page() works, so does MODULENAME_preprocess_page - See http://drupal.org/node/223430 for the specific order that these preprocess functions are called.

Now, as for setting up the template. You define it using http://api.drupal.org/api/function/hook_theme - As an example from the block module:

function block_theme() {
return array(
'block' =&gt; array(
      'render element' =&gt; 'elements', 
      'template' =&gt; 'block',
    ), // Omitted remainder.


Notice the 'template' attribute. That maps to block.tpl.php. So assume the following:

function myModuleName_theme() {
return array(
    'my_themehook_special' =&gt; array(
        //notice I am setting this up to look for the file in a subdirectory of the module
        'template' =&gt; 'moduleSubdirectory/filenameOfTemplate',
        'arguments' =&gt; array('yourArgumentObject' =&gt; null),
    )
);
}


That would register your template. Check out this blog post for more: http://www.trevorsimonton.com/blog/tplphp-hooktheme-drupal-variable-template-module