McGinn was voted player of the season by the fans last term after making the move from Easter Road for a fee believed to be in the region of £2.5 million.
He even bagged what would prove to be the winning goal in Villa's 2-1 play-off final victory over Derby County.
Speaking after the deal was announced, McGinn said: “I have loved every minute of my time at Aston Villa and I am delighted to commit myself to the club for the long term.
Villa CEO Christian Purslow added: “We are delighted to secure John’s services for the long term at Aston Villa.
“He is the type of player Dean Smith and our ownership group want to build our club around; young, determined, athletic, technically-gifted and passionate about winning."
McGinn spent three highly productive years at Easter Road, winning both the Ladbrokes Championship title and the 2016 Scottish Cup.