Luis Enrique made the announcement at a news conference after Barca thrashed Sporting Gijon 6-1 at the Nou Camp on Wednesday to keep up their bid for a third league title under the management of their former midfielder.
"I would like to thank the club for the confidence they have shown in me, it's been three unforgettable years," said Luis Enrique, who has won two Liga titles, two King's Cups and the 2015 Champions League since succeeding Gerardo Martino in 2014.
Luis Enrique said he had met with Barca directors Albert Soler and Robert Fernandez before this season to discuss the possibility of not renewing his contract.
"They told me there was no hurry to make a decision, but now that moment has arrived," he added.
"This is a very difficult decision for me which I have thought about for a very long time but I think I have to be loyal and do what I think is right."
Barca top the standings on 57 points, one ahead of arch-rivals Real Madrid who have played one game fewer.
Luis Enrique has also led his team to the King's Cup final but suffered heavy criticism after Barcelona were crushed 4-0 by Paris St Germain in their Champions League last 16 first-leg game two weeks ago.
Luis Enrique followed in the footsteps of former team mate Pep Guardiola in leading Barca to the treble in his first season in charge, although his reign has also witnessed turbulent moments.
The coach was reported to be on the brink of dismissal in January 2015 due to his rocky relationship with Lionel Messi after leaving the Argentine talisman out of the starting line-up.
While he has overseen spectacular football, fired by the prolific attacking partnership of Messi, Neymar and Luis Suarez, Luis Enrique has been criticised for abandoning the team's style of play perfected by Guardiola which was geared around controlled possession in midfield.
He bore the brunt of criticism for the harrowing defeat by PSG which has left Barca on the brink of their earliest elimination from the Champions League in a decade.
Luis Enrique said he had become exhausted from the constant pressure that comes with the Barca job and needed time out to recover, echoing Guardiola's words when he stepped down in 2012.
"In my work I am constantly looking for solutions and that means I get no time to rest, I need to rest and that's my main motive for leaving," he said.
Guardiola paid tribute to his former team mate.
"With Luis Enrique's farewell, fans lose someone who was the perfect coach for Barcelona. The football in the last three years has been incredible," the Manchester City manager said on Twitter.
Midfielder Ivan Rakitic said he and the rest of the Barca squad were taken aback when Luis Enrique revealed the news to them in the dressing-room.
"We knew nothing about it," Rakitic told Croatian media. "First he told the team about his decision We were left stunned and at a loss for words. We want to end the season successfully and enjoy what is left."
Barca president Josep Maria Bartomeu also praised the departing coach.
"We're very happy with the work he has done up to now and we have to accept his decision and support him. Luis Enrique will leave in the summer and we've had a super coach for the last three years," he said.