NEW YORK (TheStreet) -- Stocks held onto solid gains booked earlier in Monday's session after Greece and its European creditors sealed a debt deal following months of back-and-forth deliberations.

The S&P 500 rose 0.93%, the Dow Jones Industrial Average gained 1.1%, and the Nasdaq was up 1.3%.

European markets rallied Monday after European leaders agreed to a bailout of 86 billion euros ($95 billion) to ensure Greece remains in the euro. Greece must impose strict spending cuts in exchange for the additional funds. The deal helps prevent Greece from exiting the eurozone, an unprecedented and potentially catastrophic outcome for the region.

"It's much better than anyone really expected," Kathleen Brooks, head of research at City Index, told TheStreet. "We were getting into a really desperate situation. By next Monday ... Greece had to repay the ECB 3.5 billion euros. It didn't have the money to do that so it has avoided another default. This has been certainly the best outcome and avoids that near-term default which would definitely have meant the collapse of the Greek banking sector."

The Greek chapter hasn't been closed yet, though, with the country's parliament still to vote on the deal's terms on Wednesday.

"There are still a variety of details to be agreed upon after the fact," wrote CRT Capital's David Ader and Ian Lyngen in a note. "Greek banks are still closed and the July 20 ECB payment of 4.2 billion euros looms ... We're apprehensive that although ostensibly a compromise has been reached, the market remains vulnerable to headlines related to the ultimate completion of the deal."

Microsoft (MSFT) was one of the best performers on the Dow after setting a July 29 launch date for its new Windows 10 operating system. The software giant will provide its upgraded system to PC owners free of charge for a limited time. Shares jumped 2% to $45.52.

Netflix (NFLX) was on track for a record close on Monday after hitting an intraday high of $716.16 earlier in the session. Shares of the streaming giant gained 4.5% to $712.88 by mid-afternoon, rallying in line with broad-market gains and ahead of its earnings report after the bell Wednesday. Shares would have to close above $681.19 to beat the previous record close set in June. 

Anacor Pharmaceuticals (ANAC) jumped more than 50% after preliminary data showed a positive response to its drug candidate for those suffering from atopic dermatisis, an itchy skin condition. The company expects to file a new drug application in the first half of 2016. 

Remy International (REMY) spiked 42.3% on Monday after BorgWarner (BWA) agreed to purchase the electrical component manufacturer for $950 million in cash. BorgWarner, an auto parts company, expects the deal to close by the fourth quarter.

Casino stocks with exposure to Macau were rallying alongside Chinese markets and on news Macau's government is considering easing smoking bans on casino floors. The latter action is likely in response to waning tourism at the gambling destination. Las Vegas Sands (LVS), Wynn Resorts (WYNN), Melco Crown (MPEL) and MGM Resorts (MGM) were trading higher.

Groupon  (GRPN) spiked 5.6% after analysts at Macquarie upgraded shares to 'outperform' from 'neutral'. The firm said the revision was justified given a recent pullback in the company's share price.

Comcast (CMCSA) is jumping into the TV-streaming game after announcing its own service called Stream. The service, which will cost $15 a month, will allow customers to watch 12 channels including HBO on their mobile devices. It will initially launch in Boston by summer's end.

Appliance company Jarden (JAH) has confirmed it will acquire privately held Waddington Group for around $1.35 billion from investment fund Olympus Partners. The purchase of the disposable kitchenware company is expected to close in the third quarter.