Chasing 334, Sri Lanka lost wickets after a terrific start to suffer their second defeat.