Tens of thousands gathered in Riyadh and Mecca to pay their respects, while foreign leaders congregated in the Saudi capital for the funeral