Merritt, who has been part of all six campaigns over the last decade, claimed his 11th world championship medal.
The 2008 Olympic 400m champion ran his leg in 44.16 and crossed the line for gold in two minutes 57.82 seconds, the best time of the year.
“I just kept my cool, kept calm and made the move when I knew I had to,” the 29-year-old, who ran the heats in 2005 and the last five finals, told reporters.
“I felt strong all the way up until 300m and I started lifting and closed the show. It feels good. We are excited about it and looking forward to Rio for next year.”
Trinidad and Tobago, who led after the first three legs, took silver in a national record 2:58.20 and Britain pipped Jamaica to third place in 2.58.51.
Merritt, who won silver in a thrilling individual 400m final, will have been delighted to avoid the fate of the American 4x100m squad, who were disqualified after a botched exchange, while the women’s 4×400 squad were pipped by Jamaica.
It briefly looked as if Jamaica’s men were going to triumph too when anchor Javon Francis tore to the front on the back straight but he paid a heavy price for going too soon as he was caught on the line by Britain’s Martyn Rooney in a photo-finish.
The similarly red-suited American and Trinidad and Tobago teams had dominated the race until Francis’s explosive intervention with 300 metres to go.
World junior champion Machel Cedenio was unable to close the gap on Merritt but he was delighted to move past Francis and get one over on his region’s sprinting powerhouse.
“I’m glad we managed to send the Jamaicans back,” the teenager said.
“We are just a small Caribbean nation so those moments are very important for us and the achievement is just amazing.
“We are ready for a big celebration, wine and juice.”
Rooney, who became a father for the first time this week, paid tribute to his team mates and was also particularly pleased the squad got the baton round, unlike the British 4×100 team on Saturday.
“The group of people we have in this team really rose to the occasion. We all came here to do the job,” said the 28-year-old, who won a relay silver at the 2009 world championships and who ran a lifetime best in the heats of the individual event here.
“No one came just to be here and enjoy Beijing. They came here to make the Bird’s Nest their home and perform to a high standard,” he added.
“Another world medal. It’s incredible and I’m really happy I didn’t mess up for them.”
The Bahamas, who beat the United States to win Olympic gold in London three years ago, were disqualified in the heats.
(Editing by Ed Osmond)