If you have been denied, you have a right of appeal. They must explain the denial and give you a chance to refute the information that prompted the denial. However, if any of the reasons for denial in the law apply to you, don't waste your time. Those criteria are absolute. For a quick reference for those criteria, see the yes/no questions on the 4473. If you answer yes to any of them (except the first one), you may not own a gun. The first question asks if you are truly the purchaser. That question requires a yes answer, but a no does not disqualify you from owning a firearm. It does disqualify you for that purchase because you have just admitted to making a straw purchase.
Purchasing a firearm for a bona fide gift is not a straw purchase. However, before you gift a firearm, be sure that the person you are gifting it to can lawfully receive it. It is possible to commit a felony by gifting a firearm.
I don't know if any of this helps you. If not, I hope someone with good information about your exact situation contacts you. But a security clearance should have nothing to do with the background check, although failing one will likely mean failing the other. Passing one won't mean that you will pass the other.