diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index da610e430f37dd7642dc02131a5834cbae6cc705..7bd6f7d1e47c4cdae56f8c7bcb29db74cd6a6865 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -1157,7 +1157,8 @@ def handle_timeout(state, is_mine, syncing_user_ids, now):
         # If there are have been no sync for a while (and none ongoing),
         # set presence to offline
         if user_id not in syncing_user_ids:
-            if now - state.last_user_sync_ts > SYNC_ONLINE_TIMEOUT:
+            sync_or_active = max(state.last_user_sync_ts, state.last_active_ts)
+            if now - sync_or_active > SYNC_ONLINE_TIMEOUT:
                 state = state.copy_and_replace(
                     state=PresenceState.OFFLINE,
                     status_msg=None,