Finally I have found a workaround for this problem. I logged in to the application by admin programmatically using below code,
global $user;
$user = user_load(1);
drupal_session_regenerate();
drupal_goto('user');
After getting logged in, I changed the maintenance configuration from admin/config/development/maintenance.
UPDATE
Please make sure to delete the above code once the site is set back from maintenance mode. Otherwise this will give administration access to any user visiting the website.