Brandon Graham will stay with the Eagles — and now might finish his career in Philadelphia — after agreeing to a three-year contract extension Friday that keeps the veteran defensive end from reaching free agency and maintains continuity on the defensive line.

The contract is worth up to $40 million with $27 million in the first two years, according to a league source.

Graham, 30, was set to hit the open market in two weeks. Instead, he’ll stay with the team for which he’s played all nine seasons of his career since the Eagles drafted him in the first round in 2010.

He had publicly expressed his desire to remain in Philadelphia, although it was unknown if the Eagles would pay the price. Graham was expected to be a coveted free agent. The Eagles clearly prioritized keeping him.

“Honestly, me and my family, we love our situation here in Philly,” Graham said on a conference call Friday afternoon. “And for me, I've done well with what I've been given already and saving my money, and so I wasn't that far off to where I wanted to be with the Eagles. We ended up making it work. I felt like we built something here, and I wanted to finish it out if it made sense. And it ended up making sense.”

Graham left Philadelphia after the season unsure about what would happen. He had been training in his native Michigan while he and his wife expect the birth of their son later this month. Negotiations had been off and on for awhile, and Graham expected discussions with the Eagles to accelerate at the combine this week. The combine is also a place where the market for a player and a position is better understood, so it’s likely Graham had a sense of what his value would be. They found a deal that satisfied both sides by Thursday night.

“I could go somewhere and make money somewhere else, but I want to make sure it fits as far as schematically,” Graham said. “And I think Philly checks off all the boxes. I’m comfortable. I love the city. I love the upstairs … For me, it was a no-brainer. It’s all about [meeting] in the middle with each other.”

» READ MORE: Expect the Eagles, Howie Roseman to be aggressive

After an inconsistent and injury-marred start to his career, Graham has blossomed in recent years into one of their most important players while thriving in Jim Schwartz’s defense. He could never have imagine signing a third contract with the Eagles during the early-career struggles – Graham had been on the roster bubble in 2014, and seemed ready to sign elsewhere in 2015 – but he now has a chance to soon become the team’s longest-tenured players as he enters his 10th year with the team. Only Jason Peters has been on the team longer.

Although he had only four sacks last season, Graham is a disruptive player who’s capable against the run and can also rush from the interior on passing downs. His 42.5 sacks are the seventh most in franchise history, and he’s had 61 tackles for a loss and 12 forced fumbles since 2014. Graham is most known in Philadelphia for a strip sack of Tom Brady in the fourth quarter of Super Bowl LII to help lead to a victory.

Graham and Derek Barnett will likely be the Eagles’ starting defensive ends next season. Veterans Michael Bennett and Chris Long are also under contract after productive seasons, but their status with the team remains uncertain. Both players thought their production benefited from increased playing time after Barnett’s injury, so they would likely need to move down the depth chart again with a healthy Barnett and Graham back in the fold. The Eagles utilize a healthy four-man rotation, though, and it’s too soon to know how the snaps would be distribution. The Eagles also have 2018 fourth-round pick Josh Sweat coming off injury.

» READ MORE: Jason Peters and the future of Eagles’ offensive line is uncertain as free agency, NFL draft loom

For as well as Graham has played in recent seasons, he has never been a Pro Bowler. Every day during the season, he walks by a wall in the team facility honoring players who’ve been elected to the Pro Bowl. He yearns to have his picture on the wall. He also wants to be listed among the players who’ve been first-team All-Pro.

Graham explained these goals when asked whether this contract will allow him to finish his career in Philadelphia. He didn’t seem interested in considering how much longer he has left to play, but rather focused on how much more he has left to do.

“I’ve still got some goals I’m trying to accomplish,” Graham said. “For me, if anything, I was just happy to sign back with them because I can carry out some of the stuff I already started and finish strong, hopefully with another ring and party on Broad Street.”

Staff writers Jeff McLane and Les Bowen contributed to this report.