The hosts moved into a 5-1 lead, with Emmanuel Boateng scoring a hat-trick and Enis Bardhi netting twice.
Barca’s Philippe Coutinho scored a hat-trick of his own and Luis Suarez netted a penalty to set up a tense finale.
But the champions could not find an equaliser as they fell to a first La Liga defeat in 44 games.
Ernesto Valverde, beaten in the league for the first time as Barcelona boss, may regret his decision to rest top scorer Lionel Messi for the trip to 15th-placed Levante.
After coming through their game against Real Madrid unbeaten last weekend, it looked as though history beckoned for Barcelona.
No side have gone an entire Spanish top flight season unbeaten since the 1930s, when there were only 18 games in a season.
But they fell just short in a match that almost defied logic – they had only conceded 24 goals in their opening 36 games.
With the league and cup double already wrapped up, and their Champions League run long over, it makes next Sunday’s final game against Real Sociedad largely irrelevant – except to send off departing captain Andres Iniesta.
Lionel Messi had been left at home resting and it would be easy to conclude his absence cost Barcelona their unbeaten record but Barcelona had no problems scoring. It was stopping Levante from doing likewise that they could not manage.