The five-year ordeal of an American-Canadian couple held by militants came to a startling end when Pakistan forces used U.S. intelligence to free them and their three young children as they were being driven across the mountainous border between Pakistan and Afghanistan, U.S. and Pakistan officials said Thursday.

Pakistan forces tracked the militants as they shifted the family, shot out the tires of the car and secured freedom for American Caitlan Coleman, her Canadian husband Joshua Boyle, and three children born in captivity,...