There is no single airport-wide rule for how long you can stay in a lounge at San Francisco International Airport, because each lounge sets its own maximum, and the honest answer is the rule for the lounge you will actually use. Priority Pass lounges at SFO commonly cap a stay at 3 hours, the Alaska Lounge caps a Priority Pass stay at 4 hours, and airline lounges set their own limits, so the lounge’s own listing for your visit governs.

The limits, lounge by lounge
In International Terminal A, the China Airlines Dynasty Lounge and the Virgin Atlantic Clubhouse, both in the Priority Pass network, cap a stay at 3 hours, with the Clubhouse’s Priority Pass windows and capacity controls on top of that. The Club SFO, in Terminal 3, also caps a Priority Pass stay at 3 hours. The Alaska Lounge, in Terminal 1, admits Priority Pass members with a $15 co-pay per person, only when flying Alaska or a partner airline, and caps the stay at 4 hours. The Centurion Lounge and Delta Sky Club set their own access and stay rules, including Delta’s visit limits for eligible cardholders, and those rules change, so a general guide should never be trusted over the lounge’s own listing.
Capacity controls sit on top of every maximum: a lounge that is full can restrict entry, shorten a stay, or close to new entries at busy times, whatever its published maximum says. Arriving early in a long layover does not guarantee a full maximum stay if the lounge fills, and a lounge that admits you for a connecting flight may still ask you to leave at its maximum, even if your flight is later.
How to plan a long layover
Check the lounge finder or the lounge’s own page for your terminal, your membership, and your date before you travel, and plan the rest of the layover outside the lounge if your connection is longer than the maximum. For a very long layover, a second lounge visit, a day room, or time in the terminal may be the honest plan, rather than assuming one lounge will hold you for the whole connection.

