Law enforcement officers shot a man who brandished a gun near the White House on Friday while President Barack Obama was out golfing, and the man was taken to hospital in critical condition, officials and witnesses said.

The Secret Service, which protects the president, briefly locked down the White House as a precaution.

The shooting took place near 17th and E streets, near what is known as the South Lawn outside the executive mansion, which serves as the home and offices of the president.

A man who looked to be in his mid-20s walked to the gate of the White House holding a silver-colored gun pointed at the ground, said Brett Polivka, a 26-year-old visiting from Texas who was standing near the south side of the White House with his girlfriend.

"A couple officers drew their guns, went right at him and within two or three seconds we heard a gunshot," Polivka said, adding that he believed it was an officer's shot. They were then cleared from the scene, Polivka said.

The Secret Service confirmed a police involved shooting near the White House complex, reporting on Twitter that all the people under its protection were safe. The Secret Service also protects the president's family and other top dignitaries.

One person in critical condition was transported to hospital, said Oscar Mendez, a spokesman for the D.C. Fire and Emergency Medical Services Department.

Lafayette Square, a park and near the White House, was closed to tourists. U.S. Park Police and a Secret Service officer with a police dog kept tourists on the sidewalk north of the park.