Based on the comment thread - at least you are being realistic. When you end up in an unfortunate situation like this, my experience has been that the mess will not end with you working happily in the company. So - from a productivity standpoint, the first thing I'd do is start looking for a new job.
Do train the replacement the way you yourself would want to be trained - for all you know, the new guy had no part in the politics being played around him, and doing a bad job is damaging only to your reputation.
For the real question - what should you do in terms of raising the issue?
It's hard to know what all is going on in your company, but it sounds like, from your perspective - you've been wronged. I don't see a problem raising it if you can be professional, clear, and honest. Any time you see a situation that looks to violate policy or to be otherwise unethical or illegal - it should be fine in a healthy company, to raise the issue. Unless your company is particularly vindictive, and your industry is particularly tightly linked, you should be able to raise an issue professionally without damaging your career.
Things to keep in mind...
Who to Complain To:
Chances are good you can complain to:
- the HR person responsible for your interview process
- someone in their hierarchy
- (in a big company) a dispute resolution service
Usually the best approach is either to start small with direct contact to your HR contact with an informal communication - in person, on the phone or email. If you have serious concerns about retribution, a third party dispute resolution service may be available in a big company specifically to allay those concerns, and you have the option to make use of it at any time in most cases.
Generally, don't escalate up the supervisory chain unless you aren't getting timely or satisfying feedback from the person you're working with. It is totally OK to say "I'm sorry, but I can't accept that answer, I'm taking it to your supervisor". The thing NOT to do is to blast the whole chain all at once, with every medium of communication at your disposal - try to use a process where you escalate with some rationality.
When you have that first conversation, talk about your intent to lodge a complaint, but also ask if there were reasons why you weren't hired - it would be good to know, before things get ugly - why they didn't hire you. If you see those reasons as good reasons, you may decide to give up on the complaint.
How to Contact
My first approach would be a phone call or face to face meetup. If they are hard to find - book a meeting. Communicating in writing is tricky, as your nuances can be mistaken, and with HR especially - written communication gets tracked and saved.
If you can't get a meeting or they don't take you seriously - do follow up with email, restating your concerns - and save copies of anything you write.
In any case - keep your communication clean - free of insults, clearly stating the facts, and as emotion free as possible. Be polite but persistent.
Things to communicate:
A timeline is always helpful. You've clearly had a series of events leading up to this point - being clear about the sequence of events, and who did what is really helpful. Write it down for yourself so you are clear on it and research any supporting information you can - emails, phone logs, etc. Saying "they posted my resume, verbatim, as the job opening!" is less cogent than -
- We talked on X day, I was given to understand that they wanted to permanently place me, so I agreed to hand in my resume.
- On Y day, I sent this email with my resume (copy of email, copy of resume)
- On Y+n days, a job req was posted, with a verbatim translation of my resume (copy of posting).
- After m days, I was told someone else was hired - in conflict with these policies about hiring family members and waiting 2 weeks before allowing external hires.
I'd also be in the know about any details in your contract that may have impeded them hiring you. You want to know as much as you can about why they may not have wanted to hire you and if there are prohibitive fees to buying you from a contact agency, that's something to find out yourself.
Be clear with yourself
Beyond lodging a compliant, how much time do you want to spend on this? Everything you do to raise the issue will take time. If you wanted to go as far as a lawsuit, you'd need to spend money and time on a lawyer... you could also spend near endless time raising yourself up through the complaint structure of the company looking for a resolution.
As you go, figure out where your stopping point is, and where you've spent too much time. Regardless of how this pans out, it's likely that you'll want to work somewhere else in two weeks, so make sure that you first take care of yourself and your own employment needs.