WASHINGTON — An armed private security guard rode in an elevator with President Obama when he visited the Centers for Disease Control and Prevention in Atlanta on Sept. 16, violating Secret Service protocols that only agents and officers for the agency should carry a gun around the president, according to law enforcement officials.

The incident was first reported by The Washington Examiner just hours after Julia Pierson, the director of the Secret Service, defended her agency on Capitol Hill as angry lawmakers demanded explanations for a string of embarrassing incidents and security lapses in recent months.

Details of the incident at the C.D.C., which occurred three days before an intruder managed to get through the front door of the White House, were incomplete. But a law enforcement official said Tuesday that a contract security guard who provided protection for high-profile visitors managed to get on an elevator with Mr. Obama and agents from his security detail during the president’s visit to the center.

The man was taking pictures and acting “unprofessionally,” one of the officials said. The Secret Service enforces a strict “no pictures” policy for private moments around the president.