Indeed, Popper wrote, several decades before Gray's criticism, in reply to a critical essay by Imre Lakatos:
A possible rebuttal to Gray's argument appears in Popper's reply to which philosopher?
Imre Lakatos