Priceline has agreed to buy travel price comparison engine Kayak in a $1.8 billion cash-and-stock deal.

The deal values Kayak (KYAK), which went public less than four months ago, at $40 per share. Priceline (PCLN) plans to pay for the acquisition with $500 million cash and $1.3 billion in equity and assumed stock options.

Kayak shares closed Thursday at $31.04, but shot up 26% in after-hours trading after the Priceline deal was announced. Priceline shares dropped 2% after hours.

Kayak and Priceline are both based in Norwalk, Conn., but Priceline said it will operate Kayak as an independent subsidiary, run by Kayak's current management team. Pending shareholder and regulatory approvals, the companies expect the transaction to close in early 2013.

Kayak "has world class technology and a tradition of innovation in building great user interfaces," Priceline CEO Jeffery Boyd said in a prepared statement.

Launched eight years ago, Kayak made its mark in the crowded travel space with a "metasearch" engine that lets shoppers easily compare prices for flights, hotels and rental cars across many different vendors.

Priceline's past acquisitions include European hotel bookings website Booking.com, U.K. car rentals site TravelJigsaw and Asia-Pacific bookings site Agoda.com. Kayak is the first major U.S. acquisition in Priceline's 12-year history.

"Priceline is probably among the best acquirers in Internet history," said Rafat Ali, founder of travel news and information site Skift. "Booking.com turned out to be among the best acquisitions ever."

Kayak was an early pioneer in the travel field and drew attention for its innovative approach, such as requiring all of its employees, including its programmers, to field customer service calls.

It has lately faced intensifying competition from giants like Microsoft's Bing Travel, and Google (GOOG), which snapped up airline search company ITA. It's also being challenged by upstarts like Hipmunk, which stole some of Kayak's thunder with a widely praised search interface.

Kayak also on Thursday released its third-quarter results. The company reported net income of $8 million on sales of $78.6 million, up 29% from a year ago.