Police and the ambulance service were called to the scene on the River Nith near Dumfries at around 7.30pm yesterday.
The 15-year-old had been swimming with six other friends near Carnsalloch Gardens, Kirkmahoe, when it is believed he suffered problems while under the water.
He was taken to Dumfries and Galloway Royal Infirmary, where his condition is described as critical.
Police are urging parents to remind their children of the dangers of playing in or near water.
They warn underwater currents may be stronger and the water deeper than people think, and there may also be thick undergrowth under the water in which people could become entangled.