Gomarsall has won 23 England caps and is a candidate for the two-Test summer tour of South Africa. England head coach Brian Ashton will announce his 32-man squad on Tuesday.
Quins rugby director Dean Richards said: "Andy's skill and experience in such a key position within the team is exactly what you need in the Premiership, so to have secured his services for the next two years is great news for the club.
"His performances have played a big part in our achievements from this campaign and he will be a key figure as we look to build on this next season."
Quins have also retained the services of England sevens internationals Charlie Amesbury and Tom Williams, who have agreed one and two-year deals respectively.