Barca last endured a league defeat at the Camp Nou against Alaves in September 2016 but, following 42 games unbeaten, their run was ended by a brilliant, counter-attacking display from Betis.
Three hours later, Real Madrid were putting the finishing touches to a 4-2 win away at Celta Vigo, a result expected to earn Santiago Solari an extension to his tenure as coach.
Real have now posted four consecutive victories since Solari was put in temporary charge while the gap behind Barca has been reduced to four points.
Big pressure on Lopetegui as Madrid beaten by Levante
"He has done excellently," Madrid club director Emilio Butragueno said afterwards. "We are very happy with how things have gone."
On his future, Solari said: "We'll see. I don't usually plan too far ahead but in principle, it´s my day off tomorrow."
Barca's shock defeat came despite a return for Messi, whose two goals, one from the penalty spot and another deep into injury-time, proved little more than consolations.
"We don't leave with the feeling Betis were the better team," coach Ernesto Valverde said. "I don't want to take any credit away from our opponent but we could have countered them better."
It was the first time ever that Messi scored twice and Barcelona lost, but they stay top of the table, even if three clubs now lurk just one point behind.
Atletico Madrid, whom they face at the Wanda Metropolitano after the international break, Sevilla and Alaves lead the chasing pack.
Alaves beat Huesca 2-1 earlier on Sunday, while Sevilla won by the same scoreline at home to Espanyol, Wissam Ben Yedder prodding in an 89th-minute winner.
Madrid flourish under Solari
"Top of the table is fine, I won't deny it," Valverde said. "It should also help us to realise it is never easy to win."
Betis' reward for beating Barca is to climb to 12th. Quique Setien's side may have pulled back on the sumptuous, attacking football that earned them a sixth-place finish last term but, in full flow, they remain one of Spain's most difficult opponents to stop.
"We have been a brave team in every way," former Spain international Joaquin said. "Winning at the Camp Nou requires concentration and doing everything very well. We played a great game."
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ