Justin Bieber joined Ariana Grande for a surprise duet at Coachella on Sunday, marking his first onstage performance in two years.

Grande kicked off her second headlining set at the music festival in Indio, Calif., on Sunday with several hits from her albums “Sweetener” and "thank u, next” before bringing out Bieber toward the end, People magazine reported.

“We thought it might be fun to do something for you guys,” Grande said before Bieber got on stage to perform his 2015 hit song “Sorry.”

“I haven’t been on stage in like two years. I came out here I had no idea I was going to be on stage tonight,” Bieber told the Coachella crowd. “So anyways this is my first time on stage in two years. I had to get my groove back, my swag back, you know what I’m saying? So, thank you so much, Coachella. Thank you so much, Ariana Grande. We love you so much, man. Thank you so much.”

“By the way, album coming soon,” he added.

The “What Do You Mean?” singer also took to Twitter to thank Grande and Coachella.

HAILEY BALDWIN GUSHES ABOUT JUSTIN BIEBER IN INSTAGRAM POST: ‘YOU MAKE ME HAPPIER THAN I’VE EVER BEEN’

“Thank you @ArianaGrande . Thank you @coachella. That felt right. Love you,” the 25-year-old singer wrote.

Bieber last took the stage in July 2017 for his “Purpose” world tour, but he abruptly canceled the final 14 shows “after careful consideration.” He told “Vogue” in February that he decided to stop touring because he got “really depressed.”

“I haven’t talked about this, and I’m still processing so much stuff that I haven’t talked about. I was lonely. I needed some time,” he said.

CLICK HERE TO GET THE FOX NEWS APP

The singer, who got married to Hailey Baldwin in September, also wrote in an Instagram post last month that he was stepping away from music to focus on “repairing” some “deep rooted issues.”

"Music is very important to me but Nothing comes before my family and my health," Bieber wrote in his post, before going on to promise his 106 million followers that he will return with a "kick a-- album ASAP."