On Wednesday eight Taliban gunmen wearing suicide vests attacked three Afghan government buildings killing twenty people.

The attack comes just before a planned visit the new U.S. envoy to the region.

The attacks in a city dense with barricades and armed guards underscored the difficulty of fending off the Taliban even with abundant troops and weaponry as the U.S. beefs up its presence.

Three text messages were sent to the leader of their terror cell in Pakistan by the assailants ahead of the launch of the assault, said Amrullah Saleh, chief of Afghanistan's intelligence agency, underlining the links between militants in the two countries, the Associated Press reported.

Five men armed with assault rifles and grenades attacked the Justice Ministry in late morning, shooting at workers and temporarily trapping the minister and scores of others inside, witnesses said. The gunmen appeared to hold the building for about two hours before Afghan security forces regained control about midday, according to an AP reporter on the scene.

At about the same time, two men in suicide vests blew themselves up at the ministry's correction department across town. A third assailant in a suicide vest was shot as he tried to force his way into the Education Ministry, about a half-mile (one kilometer) from the Justice Ministry attack, said Defense Ministry spokesman Gen. Mohammad Zahir Azimi.

At least 20 people were killed in the attacks and 57 wounded, said Mohammad Hanif Atmar, the interior minister. All eight attackers died, Azimi said, bringing the total death toll to 28.

According to Taliban spokesman, Zabiullah Mujaheed, the attacks were in response to the alleged mistreatment of Taliban prisoners in Afghan government jails.