I have had direct experience with this and yes new aircraft are sold with a warranty like a car, say for 3 years or 5 years and x hours. The OEM may maintain local service centers, and a/c under warranty may be sent there for moderate fixes, although most of the time the airline fixes the problem itself and charges back the OEM for labour and gets parts provided by Spares free of charge (to the extent it's worth their while to do so for labour chargebacks; sometimes the administrative hassle to recover, say, 5 manhours at an overhead allowance of 50 or 60 bucks an hour isn't worth the trouble).
In extreme cases problem aircraft have been known to have been taken back by the OEM to prevent an angry operator from canceling a large ongoing order, or some such situation where it's important to mollify the customer.
Sometimes the OEM will use in-house product support teams to go out and do more significant work on aircraft under warranty, especially if the airline doesn't have the resources in-house, for free.
The OEM's program office will have a warranty administration group that manages all this. A significant sum of money is budgeted by the OEM to cover warranty reimbursements and you could say this is built into the price (I dimly recall that on the Regional Jet program there was a budgeted warranty allowance of about a quarter or half a million $ per aircraft, but it may have been more than that).
Once it's out of warranty, well, you're on you own buddy. You'll pay for spares, and for support from the OEM beyond basic help desk advice. Major mods may or may not be provided free of charge to out of warranty a/c, depending on how nearly broke the OEM is budget-wise, or how much the bad publicity will hurt. An airline may get satisfaction, on old out-of-warranty costs it was unhappy about, as part of a package negotiated on a new aircraft sale. This is common on re-orders where airlines add more aircraft to an existing fleet.
Airlines may also negotiate (if they're smart) "AD clauses" where the OEM agrees to pay parts and labour for work required under a mandatory AD, with it's own, later, expiry date.