The Sensex ended the session with a 317-point gain to close at 77,405.50, while the Nifty advanced 105 points to finish at 23,592