I really had to go and the men's room had one toilet and a guy was in there taking his sweet time.
So I made the decision to go in the (empty) women's room that had 3 stalls. I was nearly done taking care of business when the door was flung open and 5 women came in. Two occupied the other stalls, the other 3 waited. I was done and getting stressed about how to get out. I decided to hunker down and stay quiet and hope they would finish quickly in the other two stalls and leave. After a few more minutes, one of the other women had cycled into the other 2 stalls but the other two were still waiting. They started knocking on my door and asking me questions in Spanish. I had no way of verbalizing an answer without 1) giving myself away as a man and 2) giving myself away as an American tourist (I know zero Spanish).
After looking for a window or other escape route (the small window definitely wouldn't fit me and it was locked), and as their knocking and audible level of concern raised, I finally just decided to own it and act like I was dumb. I opened the door and made direct eye contact with two Peruvian women, one of whom...was wearing a police officer's uniform...and both of whom were super surprised. I just said "Ooops - sorry!" in English and made a beeline out the door, grabbed my BYU study abroad classmate who was laughing hysterically, and booked it out of the front door of the restaurant.
I wonder what those two women thought...probably just reinforced a stereotype of dumb American tourists. Also...it turns out the men's room opened up 30 seconds after I went into the women's.