The Catalan outfit lost their first home match in two years on Sunday as they allowed Sevilla and Atletico Madrid to gain ground in the title race.
Messi also helped set up a goal by substitute Arturo Vidal, but the league leaders were always trailing after Junior Firpo opened the scoring in the 20th minute.
Ernesto Valverde's team stay top of the table but their lead is down to one point on Atletico Madrid, whom they play at the Wanda Metropolitano after the global break, and Alaves, who had beaten Huesca 2-1 in the day's early match.
Barca's previous home defeat came on 10 September 2016, when they lost 2-1 to Alaves.
"When you come here, you always expect to suffer but we knew if we showed character and overcame the stress we could play well and have the ball, and Barca are a team that suffers without the ball and struggles to get it back".
Barcelona fell behind to two first-half Betis goals before Lionel Messi halved the deficit from the penalty spot just after the hour mark.More news: Brazilian GP: Mercedes fear Ferrari are favourites
More news: Meg Ryan engaged to singer John Mellencamp
More news: 3 key races in Florida, Georgia may be headed to recounts
There was still time for Messi to grab his second of the game deep into stoppage time but Betis clung on to record a memorable win. "Winning at the Camp Nou requires concentration and doing everything very well".
"We paid dearly for not playing well in the first half".
William Carvalho's superb pass found Firpo, who unleashed a fine right-footed drive past Marc-Andre ter Stegen. He weaved inside Sergi Roberto and struck hard into the net.
Betis were soon pouring onto Barca´s defence again, with Junior's cross evading everyone before finding Lo Celso on the opposite side of the box.
Betis had squandered several chances before Junior broke the deadlock although it took an outstanding save from visiting goalkeeper Pau Lopez, formerly of Barca's neighbours Espanyol, to prevent Clement Lenglet from levelling before Joaquin made it 2-0. His cute cut-back picked out Joaquin, who stabbed in Betis' second.
Former Blaugrana star, Tello with his second assist of the night as Betis ensured they maintain their two goal lead in the game.
Messi added his second in injury-time, tapping a Vidal pass over the line.