The Dirk Nowitzki era will continue in Dallas.

The Mavericks and their 13-time All-Star have agreed to the framework of a two-year, $40 million deal, ESPN first reported Tuesday. Nowitzki had opted out of his $8.7 million option for the 2016-17 season in late June, making him a free agent.

Story online soon @espn: Mavs and Dirk Nowitzki have come to terms on the framework of a new two-year, $40 million deal, league sources say.

— Marc Stein (@ESPNSteinLine) July 5, 2016

More from FoxSports

Nowitzki, 38, has spent his entire 18-season NBA career with the Mavericks, who drafted him ninth overall in 1998 out of Germany.

The 2006-07 NBA MVP and 2010-11 NBA Finals MVP has averaged 22.0 points, 7.9 rebounds, 2.5 assists and 0.9 blocks per game during his career. This past season, he averaged 18.3 points, 6.5 rebounds, 1.8 assists and 0.7 blocks per game. Nowitzki ranks sixth on the NBA's all-time scoring list with 29,491 points.

Nowitzki has averaged 25.3 points, 10.0 rebounds, 2.5 blocks and 0.9 blocks in 145 playoff games. He led the Mavs to the NBA title in 2011.