form validation messages are not rendered immediately
The problem is that Drupal has already finished setting messages for the current request when it gets to processing your form. To get things working properly call drupal_get_form in template_preprocess_page:

function myThemeOrModulename_preprocess_page(&amp;$variables) {
  // For node templates.
  // $variables['node']-&gt;my_form = drupal_get_form('form_name');
  // For page templates.
  $variables['my_form'] = drupal_get_form('form_name');
}


Then render the form in your template file:

&lt;?php print render($my_form); ?&gt;


There was another issue for which I don't know the cause of currently, but adding $variables['messages'] = theme('status_messages'); (see theme_status_messages) inside the same preprocess_page function solved it.