VMI, based in Lexington, has held the prayers since the 1950s. The ACLU sued the school last May on behalf of two cadets.
In his ruling Thursday, U.S. District Judge Norman Moon called the ceremonies a "state-sponsored religious exercise."
"Because the prayers are drafted and recited at the direction of the institute's superintendent, the result is that government has become impermissibly entangled with religion," said Moon, in his ruling.
At a news conference called in reaction to the ruling, Virginia Attorney General Jerry Kilgore announced plans to appeal the ruling.
"It's a shame today that while American soldiers are fighting for our liberty in places like Afghanistan, cadets training to be soldiers cannot pray for their safety," said Kilgore.
According to Kilgore, the prayer is part of a "militaristic ceremony" that is central to VMI's mission and therefore it is a matter of academic freedom.
Every night, cadets march into the mess hall in formation. Before they are served dinner, a member of the corps reads a non-denominational prayer.
A VMI spokeswoman says all school prayers will be discontinued immediately.
One of the cadets who sued, Neil Mellen, 23, said after the ruling: "I hope that those who do value prayer realize that there is no end to prayer in the mess hall. They can pray in their own personal way, which is better than the bland way that they're doing it now."
© MMII The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed