I have found what I need.
$messages = elgg_view('page/elements/messages', array('object' => $vars['sysmessages']));
That will retrieve the messages saved with register_error and system_message.
Sorry for asking. Hope it helps someone.
If you don't see system messages, your theme must have modified the page shell. I would look there first.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.