BARCELONA, Spain — Lionel Messi scored twice on his return from a broken arm but Barcelona conceded four goals and was reduced to 10 men in a 4-3 home defeat to Real Betis in the Spanish league on Sunday.

The loss ended an unbeaten run of 42 consecutive home games for Barcelona in the league dating back to a 2-1 defeat to Alaves on Sept. 10, 2016.

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.

Messi returned to the field at Camp Nou three weeks after he broke a bone in his right forearm during a win over Sevilla. Barcelona won four games and drew one without him, including a 5-1 rout of Real Madrid.

"We came from a run of very good games and results in which we were all playing well but we were lacking something overall (on Sunday)," said Barcelona manager Ernesto Valverde. "They won the match in the first half."

Barcelona hadn't lost at home in any competition since Valverde's debut in the Spanish Super Cup at the start of the 2017-18 season, when it lost 3-1 to Real Madrid.

Barcelona's second league loss of the season left it one point ahead of Atletico Madrid, which it visits next round after an international break. Espanyol can pull level on points with Barcelona if it beats Sevilla later Sunday.

Betis undid Barcelona by pressing high up the pitch and mounting quick attacks.

Joaquin Sanchez made it 2-0 for Betis before halftime. After Messi pulled one back from the penalty spot, Barcelona goalkeeper Marc-Andre ter Stegen let a shot by Giovani Lo Celso slip through his hands to restore Betis' two-goal cushion.

Messi briefly rekindled the comeback in the 79th when he threaded a pass forward for substitute Munir El Haddadi, who laid off for Vidal to reduce the deficit to 3-2.

But Barcelona was left with 10 men in the 82nd when Ivan Rakitic earned a second booking for a hard tackle on Lo Celso. A minute later Firpo led another attack for Betis from the left flank, passing for substitute Sergio Canales to slide and push his cross home.

Messi scored his second goal deep in stoppage time. The Argentina forward leads the competition along with teammate Luis Suarez with nine goals each.

Betis rose to 12th after its first win in five rounds.

"We played a great match against a great team," Betis coach Quique Setien said. "We showed our character and knew how to read the match perfectly."

___

More AP soccer: https://apnews.com/tag/apf-Soccer and https://twitter.com/AP_Sports