Which of these meanings for the word "pet" came first?

Solution 1:

Etymonline to the rescue:

"tamed animal," originally in Scottish and northern England dialect (and exclusively so until mid-18c.), of unknown origin. Sense of "indulged child" (c.1500) is recorded slightly earlier than that of "animal kept as a favorite" (1530s), but the latter may be the primary meaning. [...] The verb is 1620s meaning "treat as a pet;" the sense of "to stroke" is first found 1818.

So the noun came first.