General manager Craig MacTavish announced the deal via Twitter on the eve of an arbitration hearing.
The 23-year-old centre had 14 goals and 24 assists in 48 games last season.
"So happy to remain an Edmonton Oiler for at least three more years," tweeted Gagner. "Thanks to everyone for the support. Time to get to work."
Gagner reportedly was asking for US$5.5 million a year, with Edmonton offering $3.5 million.
He earned $2.275 million last season.