A gas leak that prompted the evacuation of 2,500 people and a shelter-in-place order for 2,500 more in downtown San Jose Friday has been capped, San Jose fire officials said.

Crews were able to stop the flammable gas leak from a pipe at the intersection of South Market and West Santa Clara streets around 5 p.m., but traffic in the area may be diverted throughout the night as fire and hazardous materials crews investigate possible pockets of gas trapped in nearby buildings, according to San Jose fire Capt. Mike Van Elgort.

PG&E crews dug into the roadway at the intersection of South Market and West Santa Clara streets to repair the leaking natural gas pipe using a "safety cage" to hold up the sides of the trench and underground wiring there, Van Elgort said.

About 2,500 people were evacuated from office buildings on a two-block area of Market, First and San Pedro streets and the 2,500 people who were told to shelter in place were allowed to go home, the fire captain said.

Fire crews began evacuating workers from buildings in the area of the leak at 1 S. Market St. after it was reported at 11:07 a.m., according to fire officials.

Hazmat personnel will remain on scene for as long as needed to test the buildings affected by the leak for any pockets of flammable gas that could remain inside, Van Elgort said.

Until the tests are completed, no one will be allowed to access the buildings, which mostly house offices with daytime hours.

Ruptured gas line forces evacuations in downtown San Jose. Photo via @brneyegirlsj #breaking pic.twitter.com/L00rklY9kk — NBC Bay Area (@nbcbayarea) November 7, 2014

According to PG&E, a non-utility construction crew was using digging equipment this morning when it ruptured the 4-inch pipe and gas started to escape.

Traffic has been diverted from Santa Clara Street to as far south as Park Avenue to other routes, Van Elgort said.

The VTA Downtown Customer Service Center is among the evacuated buildings and train lines 22, 522, 68, 17, 168, and 181 were being rerouted, VTA officials said.