The Air Force is divesting itself of its fleet of C-27J Spartan cargo planes, like this one seen in a 2010 photo. (Bekah Clark/Air Force)

The Coast Guard will take control of the last of the Air Force’s C-27J cargo planes, putting an end of a years-long saga over finding a long-term home for the twin-engine aircraft.

The planes will be transferred to the Coast Guard within six to 12 months, with the goal of filling “medium range surveillance USCG missions such as maritime patrol, drug and migrant interdiction, disaster response, and search and rescue,” according to a press release from Italian contractor Alenia Aermacchi, which built the planes.

The C-27J is a tactical transport designed for use on small, rough airfields. The Air Force initially planned on fielding 38 planes before deciding they were too expensive to operate. That decision set off a firestorm of controversy in Congress, where members were eager to make sure local Air National Guard units received the platforms.

The Air Force purchased 21 planes. In November, the service transferred seven to US Special Operations Command. The US Forest Service had also submitted a request for the planes.

Congress has made sure the Forest Service won’t lose out entirely. Under the 2014 National Defense Authorization Act passed last month, the transfer of the C-27Js is dependent upon the completion of the Coast Guard’s transfer of seven C-130s to the Air Force, which will then be required to shoulder the cost of modifying the four-engine planes into firefighting aircraft for the Forest Service.

The budget also requires the secretary of the Air Force to “provide the Committees on Armed Services of the Senate and the House of Representatives, not later than January 30, 2014, a quarterly report or briefing on the cost, schedule, and execution of notable events related to the aircraft transfers and modifications required within the provision.”