diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index d5464d5..67447fb 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -631,6 +631,7 @@ IRC_PROTOCOL_CALLBACK(join)
 IRC_PROTOCOL_CALLBACK(kick)
 {
     char *pos_comment;
+    int rejoin;
     struct t_irc_channel *ptr_channel;
     struct t_irc_nick *ptr_nick, *ptr_nick_kicked;
 
@@ -696,7 +697,13 @@ IRC_PROTOCOL_CALLBACK(kick)
          * more
          */
         irc_nick_free_all (server, ptr_channel);
-        if (IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTOREJOIN))
+
+        /* if localvar_autorejoin exists it has higher priority than server option */
+        rejoin = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTOREJOIN);
+        if (weechat_buffer_get_string (ptr_channel->buffer, "localvar_autorejoin"))
+            rejoin = weechat_config_string_to_boolean(weechat_buffer_get_string (ptr_channel->buffer, "localvar_autorejoin")) ? 1:0;
+
+        if (rejoin)
         {
             if (IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTOREJOIN_DELAY) == 0)
             {
