A mother who was travelling with her two daughters was also taken to hospital.
Police said it appeared a Vauxhall Corsa travelling south on the A719 lost control, crossed the centre line and struck an on-coming Skoda Fabia car.
The accident happened near Jamestown Farm not far from Maidens in South Ayrshire at around 8:40pm on Tuesday. The 18-year-old driver of the Corsa died at the scene and his front-seat passenger, also an 18-year-old man, died later in Ayr Hospital.
Another 18-year-old man, a back-seat passenger, was taken to Ayr Hospital with serious leg injuries.
The front-seat passenger of the Skoda, a 44-year-old woman, was taken to hospital and kept in for observation.
Her daughters, aged 12 and 14, and the 46-year-old woman driving the Skoda were unhurt.
The road was closed for police to investigate the scene. Police appealed for witnesses to the crash.