There are a couple of things to address here. First of all, the definition of "ugly". You may have experienced times when you were out with your friend and beautiful woman crosses your path... an 8.5, maybe even a 9. You point her out to your friend, and he thinks you're off your rocker... he'd give her a 5 if she put a bag over her head. And vice versa... you'll shake your head at the taste of some of your friends. They think they landed Charlize Theron from "The Italian Job", but they really were nailing Charlize Theron from "Monster".
But when it comes to judging the attractiveness of women, we guys are finely tuned machines and we get lots of practice. But unless you wear tight pink t-shirts and renamed yourself "Skittles", the same isn't true of you when it comes to judging the attractiveness of guys. So understand that it's possible that you aren't the world's foremost authority on what guys are "hot" and which guys are dogs.
However, some people are physically unattractive by almost any standard (a face only a mother could love). In general, people are most attracted to people who are roughly equally attractive. So if I'm a 7, then I'm going to be most attracted and most secure in a relationship with a chick who's a 7. If a 5 is with a 9, then chances are that the 5 will screw things up with the 9 because of insecurity, unless the 5 is overloaded with self-esteem. All things being equal, opposites do NOT attract over the long-term.
However, you should also understand that women have different thought processes than guys, and as a result they are not attracted in exactly the same way. Many women are more likely than men to overlook physical appearance if a guy is extraordinary in other ways. I've known women who went for guys who were less than stellar in the physical appearance department because a guy was a good musician, another because the guy was so funny that he commanded the attention of the whole room whenever he was around, and yet another because the guy devoted a lot of his free time to mentoring and helping children.
Another thing that's very important is the girl's state of mind when she meets the guy. If her self-esteem is low because of a harsh breakup, or because she's with other girls who are a little hotter so they're getting all of the male attention, or maybe she just came back from her high school reunion and feels like she has been a failure... whatever the reason, if her self-esteem has recently been lowered, she's more likely to be interested in guys she otherwise wouldn't be.
All that being said, you need to get the chip off your shoulder. The fact that you may think you're hotter than another guy doesn't make you any more deserving of female attention than that guy. In fact, it's an attitude like that -- based on jealousy and insecurity -- that is more likely to repel women away from you. And maybe into the arms of an "uglier" guy.