diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc
index de6f5d033e2042cf8d487c0607cdd9b487a8b75b..c8c5cdb343946ba785cedd0f74949081da5d52ee 100644
--- a/core/includes/ajax.inc
+++ b/core/includes/ajax.inc
@@ -362,7 +362,8 @@ function ajax_prepare_response($page_callback_result) {
     $commands[] = ajax_command_insert(NULL, $html);
     // Add the status messages inside the new content's wrapper element, so that
     // on subsequent Ajax requests, it is treated as old content.
-    $commands[] = ajax_command_prepend(NULL, theme('status_messages'));
+    $status_messages = array('#theme' => 'status_messages');
+    $commands[] = ajax_command_prepend(NULL, drupal_render($status_messages));
   }
 
   return $commands;