ESPN's Adam Schefter first reported the deal.
The deal could be worth up to $66.5 million thanks to various incentives and includes $26.5 million guaranteed.
Bortles will now be under contract through the 2020 season.
ESPN's Josina Anderson first reported the sides were discussing an extension.
Jacksonville had previously picked up Bortles' $19 million team option for the 2018 season. However, his future was uncertain beyond that since it represented the fifth and final year on his rookie contract.
But thanks to a 2017 campaign that saw him compile 3,687 passing yards, 322 rushing yards and 23 total touchdowns while contributing to Jacksonville's AFC South title and run to the conference championship game, Bortles found some new fans in the front office.
According to the Florida Times-Union's Ryan O'Halloran, "Bortles earned praise for his toughness (playing through the wrist injury), athleticism (using his legs in the playoff win against Buffalo when the passing game broke down) and leadership (raising the level of play of those around him)" from those inside the organization.
That said, Bortles will have to be much sharper from the pocket in 2018—he has tossed 64 interceptions in 62 career games—if he wants to propel the Jaguars to their first Super Bowl appearance.