Oracle Corp. agreed to pay $9.3 billion for a cloud-computing pioneer that counts Larry Ellison as a major investor, using its second-largest acquisition to try to catch up in a key area where it has lagged.

Oracle said it is paying $109 a share in cash for NetSuite Inc., a 19% premium to the company’s closing price Wednesday of $91.57.

The...