The 23-year-old contributed towards Brentford gaining promotion to the Championship last season.
"I'm absolutely over the moon. He's the one I've wanted for the last 12 months," MK boss Karl Robinson told the official club website.
"He's a name at this level, he's a goalscorer at this level and he's a Northern Ireland international too. He's got the pedigree to come in and do well."
Grigg scored five goals in 27 League One appearances for the Bees last season.