The boy was alone in the house in Mebane, about 40 miles northwest of Raleigh, when Jataveon Dashawn Hall, 19, allegedly broke in after another suspect rang the doorbell and a third waited outside.
Hall forced the boy into a closet and was stealing electronics when the child emerged, grabbed a machete and hit him in the head with the blade, drawing blood, according to the Orange County Sheriff's Office.
The boy swung a second time but missed, according to the police. The burglars then fled the scene.
"When Mr Hall realised he was bleeding, he dropped the electronics, left the home and departed with another man and a woman,” the sheriff's office said in a statement.
Hall then went to a nearby hospital to get treatment for his head wound, while a deputy waited in a public area of the hospital for more investigators to arrive, the sheriff's office said.
He was then transferred to UNC Medical Center in Chapel Hill and surveillance video shows him fleeing from there wearing a hospital gown and blue socks and with his head wrapped in a bandage.
His escape sparked a row between police and hospital staff over who was responsible for letting him escape.
The sheriff's office complained that it was not notified until the next morning. "I am not in the business of assigning blame," the sheriff said in a statement Sunday. "However, it has become clear to me that another statement was necessary to defend the actions of my deputies and investigators and to place this matter in the correct context."
But hospital staff said on Sunday morning that the sheriff didn't place a deputy to guard Hall, saying suspects under treatment "remain the legal responsibility of law enforcement." They added that "nurses and physicians cannot be both caregivers and law enforcement at the same time."
The boy's mother, Kaitlin Johnson, told North Carolina television station, WTVD-TV, “it was infuriating" that Hall had escaped from hospital.