In final act, Hezbollah-aligned leader formalizes resignation of caretaker government, complicating chaos; thousands gather to bid farewell to former army chief as he leaves palace