Print primary and secondary tabs separately
Finally I ended up like this:

&lt;?php 
  $primary = menu_primary_local_tasks();
?&gt;
&lt;ul class="tabs primary primary-with-secondary clear-block"&gt;&lt;?php print render($primary); ?&gt;&lt;/ul&gt;


The above code will return the primary links:

To print the secondary links

 if ($secondary = menu_secondary_local_tasks()) {
    $output .= "&lt;ul class=\"tabs secondary clear-block\"&gt;\n". $secondary ."&lt;/ul&gt;\n";
  }


Above code will return the secondary links for the theme.