Maj. Gen. Glenn Rieth, who is married, and the aide were caught in his office last month touching each other, officials familiar with the matter said. The officials spoke on condition of anonymity because of the sensitive nature of the matter.
Rieth, a prominent member of Republican Gov. Chris Christie's Cabinet and a childhood friend, will retire effective Dec. 15, the governor said.
"This is obviously a difficult time for his family, and General Rieth did the right thing by stepping down to address this as a personal matter," Christie said.
Rieth, 54, has commanded the National Guard for nearly a decade.
He was appointed by Democratic Gov. James McGreevey, who had his own sex scandal involving a male Cabinet member.
According to officials, Rieth reported the incident with his aide to the governor early last month and said it was being reported to the Army. He offered his resignation less than two weeks later, one of the officials said.
The woman also is married and lives just a few miles away from the Rieth and his wife; the couples knew each other socially.
As the commander of the state National Guard, Rieth leads more than 9,000 soldiers and airmen. He also oversees the Department of Military and Veterans Affairs and all state veterans' programs, commissions and facilities in New Jersey. Rieth's wife, Linda Rieth, has long played a prominent role at National Guard functions.
Glenn Rieth had a blemish-free record and was well-respected - a reason he was kept on by four governors.
Christie was especially close to Rieth because they were raised in Livingston, just outside Newark, and their families knew each other - something Christie made a point of noting in January 2010, when he announced that he was keeping Rieth in the position.
"I thank General Rieth for dedicating his career to his state and country, including nearly 10 years as New Jersey's adjutant general," Christie said.
Before being appointed as adjutant general of New Jersey in 2002, Rieth was the director of the State Army Aviation Office for the New Jersey Army National Guard. He attended The Citadel-Military College of South Carolina and has been in the military since 1980.