Kirstjen Nielsen has one hard-earned presidential signing pen.

President Donald Trump used the black marker Wednesday to sign an executive order halting family separations at the U.S. border — then handed it to Nielsen, his Homeland Security secretary.

Such pens are typically framed and displayed in lobbies and office waiting areas all over Washington as trophies of presidential proximity and power. Nielsen's was tougher to come by than most.

By the time Trump used it to reverse his policy, Nielsen had been both yelled at and praised by Trump and pilloried for repeating his falsehoods. She was forced to deny that the policy amounted to child abuse. On Tuesday night, she cut short a working dinner at a Mexican restaurant after protesters shouted, "Shame!" until, finally, she left.

Yet there she stood Wednesday in the Oval Office, right at Trump's side, as he reversed the policy she had defended — and had vowed the administration would not apologize for.

With Vice President Mike Pence at Trump's opposite shoulder, the president invited Nielsen to speak. She thanked him for his leadership.

"Great job," Trump said over his shoulder to her. He signed the order and handed Nielsen the pen.

With that, Nielsen was apparently back in the president's good graces. But fairly or not, the Georgetown and University of Virginia-educated lawyer will probably always be the face of a policy that ignited nearly ubiquitous outrage.

According to people close to the secretary, family separations weren't her idea. One person who, like the others, spoke on condition of anonymity because they were not authorized to speak publicly, said Nielsen had been "working nonstop" to find a solution.

The polarizing path Nielsen has taken is somewhat surprising for a government bureaucrat and policy wonk known more for her loyalty to White House chief of staff John Kelly and her expertise in cybersecurity than for the hard-line immigration views espoused by Attorney General Jeff Sessions and White House adviser Stephen Miller.

Nielsen, 46, was considered an expert in both homeland and national security policy who worked in President George W. Bush's administration and had a role in its handling of Hurricane Katrina.

Two years after the 2005 hurricane, Congress issued reports that faulted the White House Homeland Security Council — where Nielsen directed preparedness and response — for failing to take the lead in staying on top of the unfolding disaster.

Following Trump's election, Nielsen joined the transition team to help guide Kelly through the confirmation process to become Trump's secretary of Homeland Security. Nielsen quickly won the retired general's trust, impressing him with her work ethic and command of the issues.

Trump eventually tapped Nielsen to take over as head of DHS, and the Senate confirmed her Dec. 5.

By April, Sessions announced there would be "zero tolerance" at the border for people crossing illegally. That meant that anyone who did not arrive at a designated port of entry and claimed asylum would be arrested.

As public backlash grew, Nielsen misled the public by denying that separating families was part of U.S. policy. While the policy never specifically called for children to be taken from parents, separation became inevitable. That's because adults were detained and charged — and any children traveling with them couldn't go to jail.

Nielsen, like Trump, also suggested that it was up to Congress to fix the problem — even though the enforcement of laws happens at the president's discretion. The Bush and Obama administrations largely allowed families to stay together.

While her allies say she was merely following the law, it is likely there was another reason Nielsen tirelessly defended the policy: She has a track record of working to make her bosses happy. Also, her history with Trump was bumpy. Earlier this spring, Trump had unloaded on Nielsen during a Cabinet meeting over an increase in border apprehensions and legal setbacks, according to people familiar with the exchange but not authorized to speak publicly.

Nielsen, one person said, tried to explain that the issues were complex and that the department's powers were limited by legal restrictions. She told the president her team was doing everything it could, but the president was left unconvinced.

After news of the dressing-down spread, Nielsen did not deny the meeting had grown heated and issued a statement saying, "I share his frustration."

___

Associated Press writers Colleen Long and Jill Colvin contributed to this report.

___

Follow Kellman and Flaherty at http://www.twitter.com/@APLaurieKellman and http://www.twitter.com/@AnneKFlaherty