This is a tricky situation, as you don't want to put your existing invitation in jeopardy. There's no perfect solution to this. No general advice can address every possible situation or circumstance, so consider your options carefully.
What should you do if you have an offer in hand and have a chance to interview for another job? Consider the following, and make the choice that is right for you.
Assuming you haven't signed a non-compete and have no legal reason why you cannot work for another organization, nothing stops you from interviewing for a new job at any time – even if you've already accepted an offer. If you're still negotiating and have not signed an acceptance, you can still consider other offers.
Inform the second company.
You may want to let the second company know that you are already considering one offer and ask about the timing for their hiring process. If you believe it is worth interviewing for the new opportunity, you can try to request the organization that has made you an offer to give you more time to consider joining them.
Beware of repercussions.
Be aware, companies can rescind their offers at any time, so if you stretch things out too much with the first company before knowing if you'll have a chance at the second company, the hiring authorities at the first company may decide to cut you loose. This is a "the bird in the hand is worth two in the bush" scenario. In other words, if you have one offer, you don't want to risk everything for the possibility of another unless the reward is big enough to be worth that risk.
Assess your standing.
You'll want to assess your standing in being offered this role. Do you have the sense that you are a perfect fit, and they've been searching for someone with your skills for a long time? Or, are you more likely one of many people who are well suited to the job?
If you must make a decision before you have a chance to know your standing for the second potential opportunity, decide how much of a risk you are willing to take in hopes of landing the second job. If it's worth the risk, you can let company #1 know you are interviewing for company #2 and see if that may inspire them to provide a more competitive offer if you are a highly competitive candidate.
If company #1 improves its offer once it knows you are being considered for company #2, your best bet is to continue and finalize negotiations with that company or assume you may lose the offer altogether unless you are the perfect candidate they've been waiting to meet. Only you can decide if it is a risk worth taking.