Passing variables to custom templates
Drupal 8 uses render arrays for the structure, and drupal_render() to render them (as can Drupal 7 for themeing, incidentally). 

The examples from the change record are as good as any:

Drupal 7

// Theme a table with header and row data.
$markup = theme('table', array('header' =&gt; $header, 'rows' =&gt; $rows, 'attributes' =&gt; array('id' =&gt; 'my-module-table')));

// Render a pager.
$markup = theme('pager');


Drupal 8

// Theme is available as an element type (may have additional processing in rendering).
$table = array(
  '#type' =&gt; 'table',
  '#header' =&gt; $header,
  '#rows' =&gt; $rows,
  '#attributes' =&gt; array(
    'id' =&gt; 'my-module-table',
  ),
);
$markup = drupal_render($table);

// Pager is not an element type, use #theme directly.
$pager = array('#theme' =&gt; 'pager');
$markup .= drupal_render($pager);


There's a useful warning too:


  Also note that when preparing output for Twig templates (in preprocess functions) it is preferable to avoid calling drupal_render() whenever possible. The Twig environment in Drupal 8 will automatically render any render arrays printed in the template, allowing for manipulation by later preprocess functions and preventing unnecessary rendering if the variable is never printed in the template.