The England left-back had been a target for Manchester United and former manager David Moyes, who had two bids rejected in the summer.
However, Everton have been working behind the scenes for the last couple of months to tie the 29-year-old down to a new deal and manager Roberto Martinez revealed that had now been completed a day before they face near-neighbours Liverpool.
"I can give you good news, Leighton Baines has signed a new contract. It is for the next four years," he said.
"To be able to secure Leighton's best years at Everton means a lot, especially in this January (transfer) window where we are talking about having a strong squad going into the second half of the season.
"We are all excited that Leighton will be able to have a long-term future with the club and we are all looking forward to the second half of the season having his experience.
"It is such a specialised position it is a great boost internally but I know fans will be delighted because Leighton is more than a footballer at the club.
"You look how important he is with the daily standards, the influence he has with the younger players.
"I am just looking what Leighton can do in the next four years in the dressing room and it is going to be as good as it gets."
Martinez said the fact they had managed to stave off interest from United and persuade Baines to sign a new deal spoke volumes.
"It represents a strong intent of trying to progress and get stronger and Leighton will bring that on the football pitch," he added.
"He has been performing as one the best left-backs in European football and the best is yet to come.
"To have Leighton with the focus and tranquility to be at Everton for the long term is an incredible boost."
While Everton celebrate the news over one left-back their other option in that position, Bryan Oviedo, is set to have surgery on Monday afternoon after suffering a double fracture of his left leg in the FA Cup win at Stevenage.
"Bryan is in great spirits as it has been two difficult days," said the Toffees boss.
"He has been inundated with messages of support and affection and he is a really positive guy.
"Today is an important day as he will go for surgery and we hope he quickly recovers.
"You are usually talking about a broad timescale of five to six months but I think Bryan will be a little less than that and if he can make it to the World Cup that will be an incredible boost.
"We can't say he will miss the World Cup or not, it is still up in the air."
Martinez added he expected the future of defender John Heitinga to be finalised in the next 48 hours.
The Holland international is keen to have more playing time in a World Cup year with both Roma and Galatasaray reportedly interested in signing him.