NEW YORK - Rapper DMX has been ordered confined to his suburban New York City home by a judge who said he violated bail conditions on tax fraud charges.

Federal Judge Jed Rakoff also said Friday that the rapper must wear an electronic bracelet.

The judge says DMX repeatedly had tested positive for drugs including cocaine since his arrest last month and had a history of arrests. He also says DMX travelled at least twice without getting permission from authorities.

DMX hugged friends after his hearing. He says: "When God is for you, who can be against you?"

Prosecutors say DMX owes $1.7 million in taxes. He has pleaded not guilty.