AJAX in Form API element returned in another AJAX callback
After a lot of reading, I solved this by returning $form on the AJAX callback, and including the second button on a form rebuild. My code now looks more like this, and it's working fine:

function my_form($form, &amp;$form_state) {
  $wrapper_id = drupal_html_id('some_wrapper');

  $form['#prefix'] = '&lt;div id="' . $wrapper_id . '"&gt;';
  $form['#suffix'] = '&lt;/div&gt;';

  if (isset($form_state['my_flag']) &amp;&amp; $form_state['my_flag']) {
    $form['my_other_button'] = array(
      '#type' =&gt; 'button',
      '#name' =&gt; 'my_other_button',
      '#ajax' =&gt; array(
        'callback' =&gt; 'my_callback',
        'wrapper' =&gt; $wrapper_id,
      )
    );
  }
  else {
    $form['my_button'] = array(
      '#type' =&gt; 'submit',
      '#name' =&gt; 'my_button',
      '#ajax' =&gt; array(
        'callback' =&gt; 'my_callback',
        'wrapper' =&gt; $wrapper_id,
      ),
    );
  }
}

function my_form_submit($form, &amp;$form_state) {
  switch ($form_state['triggering_element']['#name']) {
    case 'my_button':
      //code for when user presses the first button
      $form_state['my_flag'] = TRUE; //show the other button
      $form_state['rebuild'] = TRUE; //this is necessary!
      break;
    case 'my_other_button':
      //code for when user presses the second button
      break;
  }
}

function my_callback($form, $form_state) {
  return $form;
}


I think the problem had to do with a button being outside an actual form. I hope this helps others...